mirror of
https://github.com/documenso/documenso.git
synced 2026-07-13 22:37:24 +10:00
17 lines
453 B
TypeScript
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();
|
|
};
|