make image fit

This commit is contained in:
dartz 2024-07-25 22:23:39 -04:00
parent 49c6282784
commit 1ebd111e85

View file

@ -47,6 +47,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
const url = await fetch(overlay_image);
const arrayBuffer = await url.arrayBuffer();
const overlayBuffer = Buffer.from(arrayBuffer);
const { width, height } = await sharp(png).metadata();
const overlay = await sharp(overlayBuffer)
.composite([{
@ -59,6 +60,7 @@ export function MakePrediction(election : Election, overlay_image?: string, over
tile: true,
blend: 'dest-in',
}])
.resize(width, height)
.png()
.toBuffer();