fix: thumbnail scaling

This commit is contained in:
Michal Szczepanski 2023-09-23 15:30:43 +02:00
parent 8d14ca2e60
commit 3c8beb8e85
1 changed files with 3 additions and 2 deletions

View File

@ -39,8 +39,9 @@ export class ImageResizeFactory {
const can = doc.createElement('canvas');
const wr = size.width / img.naturalWidth;
const hr = size.height / img.naturalHeight;
can.width = img.naturalWidth * wr;
can.height = img.naturalHeight * hr;
const s = Math.min(wr, hr);
can.width = img.naturalWidth * s;
can.height = img.naturalHeight * s;
const ctx = can.getContext('2d');
ctx?.drawImage(img, 0, 0, can.width, can.height);
b64image = can.toDataURL(`image/${settings.screenshotFormat}`, settings.screenshotQuality);