Files
lobehub__lobehub/scripts/cdnWorkflow/optimized.ts
CanisMinor df3ac87bb3 ✨ feat: Add changelog modal (#4800)
* ✨ 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>
2024-12-26 11:02:47 +08:00

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();
}
};