mirror of
https://github.com/documenso/documenso.git
synced 2026-07-24 08:54:20 +10:00
20 lines
458 B
TypeScript
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();
|
|
};
|