From 3c8beb8e85611f46ba2f8e73c55bd19b3486e860 Mon Sep 17 00:00:00 2001 From: Michal Szczepanski Date: Sat, 23 Sep 2023 15:30:43 +0200 Subject: [PATCH] fix: thumbnail scaling --- src/common/factory/image-resize.factory.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/factory/image-resize.factory.ts b/src/common/factory/image-resize.factory.ts index 7355e8c..2d8a480 100644 --- a/src/common/factory/image-resize.factory.ts +++ b/src/common/factory/image-resize.factory.ts @@ -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);