|
|
@ -17,8 +17,6 @@ settings.subscribe(b => { |
|
|
|
|
|
|
|
const generateThumbnail = async (f: File): Promise<Buffer> => { |
|
|
|
const can = document.createElement("canvas"); |
|
|
|
can.width = 125; |
|
|
|
can.height = 125; |
|
|
|
|
|
|
|
const [sw, sh] = [125, 125]; |
|
|
|
const url = URL.createObjectURL(f); |
|
|
@ -59,7 +57,7 @@ const generateThumbnail = async (f: File): Promise<Buffer> => { |
|
|
|
|
|
|
|
ctx.drawImage(source, 0, 0, dims[0], dims[1]); |
|
|
|
|
|
|
|
const blob = await new Promise<Blob | null>(_ => can.toBlob(_, "image/jpg")); |
|
|
|
const blob = await new Promise<Blob | null>(_ => can.toBlob(_)); |
|
|
|
if (!blob) |
|
|
|
return Buffer.alloc(0); |
|
|
|
return Buffer.from(await blob.arrayBuffer()); |
|
|
|