Files
documenso/packages/lib/utils/images/resize-image-to-gemini-image.ts
T
2025-12-09 09:19:49 +11:00

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