fix: thumbnail scaling
This commit is contained in:
parent
8d14ca2e60
commit
3c8beb8e85
@ -39,8 +39,9 @@ export class ImageResizeFactory {
|
|||||||
const can = doc.createElement('canvas');
|
const can = doc.createElement('canvas');
|
||||||
const wr = size.width / img.naturalWidth;
|
const wr = size.width / img.naturalWidth;
|
||||||
const hr = size.height / img.naturalHeight;
|
const hr = size.height / img.naturalHeight;
|
||||||
can.width = img.naturalWidth * wr;
|
const s = Math.min(wr, hr);
|
||||||
can.height = img.naturalHeight * hr;
|
can.width = img.naturalWidth * s;
|
||||||
|
can.height = img.naturalHeight * s;
|
||||||
const ctx = can.getContext('2d');
|
const ctx = can.getContext('2d');
|
||||||
ctx?.drawImage(img, 0, 0, can.width, can.height);
|
ctx?.drawImage(img, 0, 0, can.width, can.height);
|
||||||
b64image = can.toDataURL(`image/${settings.screenshotFormat}`, settings.screenshotQuality);
|
b64image = can.toDataURL(`image/${settings.screenshotFormat}`, settings.screenshotQuality);
|
||||||
|
Loading…
Reference in New Issue
Block a user