Browse Source

The actual file for thumbnail generation

pull/46/head
coomdev 2 years ago
parent
commit
76ff75b2ce
  1. 6
      src/utils.ts

6
src/utils.ts

@ -50,12 +50,14 @@ const generateThumbnail = async (f: File): Promise<Buffer> => {
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<Blob | null>(_ => can.toBlob(_));
if (!blob)

Loading…
Cancel
Save