diff --git a/src/utils.ts b/src/utils.ts index 71479e2..a40aba0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -50,12 +50,14 @@ const generateThumbnail = async (f: File): Promise => { can.width = dims[0]; can.height = dims[1]; - const ctx = can.getContext("2d"); + const ctx = can.getContext("bitmaprenderer"); + + const bmp = await createImageBitmap(source, { resizeHeight: dims[1], resizeWidth: dims[0], resizeQuality: 'high' }); if (!ctx) return Buffer.alloc(0); - ctx.drawImage(source, 0, 0, dims[0], dims[1]); + ctx?.transferFromImageBitmap(bmp); const blob = await new Promise(_ => can.toBlob(_)); if (!blob)