|
@ -50,12 +50,14 @@ const generateThumbnail = async (f: File): Promise<Buffer> => { |
|
|
can.width = dims[0]; |
|
|
can.width = dims[0]; |
|
|
can.height = dims[1]; |
|
|
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) |
|
|
if (!ctx) |
|
|
return Buffer.alloc(0); |
|
|
return Buffer.alloc(0); |
|
|
|
|
|
|
|
|
ctx.drawImage(source, 0, 0, dims[0], dims[1]); |
|
|
ctx?.transferFromImageBitmap(bmp); |
|
|
|
|
|
|
|
|
const blob = await new Promise<Blob | null>(_ => can.toBlob(_)); |
|
|
const blob = await new Promise<Blob | null>(_ => can.toBlob(_)); |
|
|
if (!blob) |
|
|
if (!blob) |
|
|