mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
* ✨ feat: Add changelog modal * 💄 style: Update changelog style * ✅ test: Add test * 🔧 chore: Add CDN workflow * ✅ test: Fix test * ✅ test: Fix test * 📝 docs: Update changelog * 📝 docs: Update cdn * refactor version * feat: 实现 changelog 初始化入口,新增后端应用层状态初始化入口 * 🐛 fix: Fix useCheckLatestChangelogId * 🔧 chore: Update types * 🐛 fix: Fix lint * upgrade * ✨ feat: Update env * 🔧 chore: Rename DOC_S3 env * ✅ test: Update test * 👷 ci: Fix build lint error * ♻️ refactor: Refactor models * 💄 style: Add feature flag * ✅ test: Fix test * 💄 style: Rm mobile modal * 💄 style: Update canonical url --------- Co-authored-by: arvinxx <arvinx@foxmail.com>
22 lines
565 B
TypeScript
22 lines
565 B
TypeScript
import sharp from 'sharp';
|
|
|
|
const WIDTH = 1600;
|
|
|
|
export const opimized = async (
|
|
inputBuffer: ArrayBuffer,
|
|
width: number = WIDTH,
|
|
): Promise<Buffer> => {
|
|
return await sharp(inputBuffer)
|
|
.resize({ width: width, withoutEnlargement: true })
|
|
.webp()
|
|
.toBuffer();
|
|
};
|
|
|
|
export const opimizedGif = async (inputBuffer: ArrayBuffer): Promise<Buffer> => {
|
|
try {
|
|
return await sharp(inputBuffer, { animated: true }).webp().toBuffer();
|
|
} catch {
|
|
return await sharp(inputBuffer, { animated: true, limitInputPixels: false }).webp().toBuffer();
|
|
}
|
|
};
|