Files
documenso/packages/lib/utils/images/resize-image-to-gemini-image.ts
T
2026-05-08 16:04:22 +10:00

17 lines
453 B
TypeScript

import sharp from 'sharp';
export const TARGET_SIZE = 1000;
type ResizeImageToGeminiImageOptions = {
image: Buffer;
size?: number;
};
/**
* Resize image to 1000x1000 using fill strategy.
* Scales to cover the target area and crops any overflow.
*/
export const resizeImageToGeminiImage = async ({ image, size = TARGET_SIZE }: ResizeImageToGeminiImageOptions) => {
return await sharp(image).resize(size, size, { fit: 'fill' }).toBuffer();
};