From ab6c89bce0f131e7e6b5f0772ae6b10fb1e4fa27 Mon Sep 17 00:00:00 2001 From: PeterJFB Date: Sun, 14 Apr 2024 18:42:49 +0200 Subject: [PATCH] Fix funny compression (ABA-827) --- src/utils/cropImage.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/cropImage.ts b/src/utils/cropImage.ts index ca1f033e..cf326a77 100644 --- a/src/utils/cropImage.ts +++ b/src/utils/cropImage.ts @@ -16,8 +16,8 @@ const cropImage = ( const canvas = document.createElement('canvas'); const scaleX = image.naturalWidth / image.width; const scaleY = image.naturalHeight / image.height; - canvas.width = crop.width; - canvas.height = crop.height; + canvas.width = crop.width * scaleX; + canvas.height = crop.height * scaleY; const ctx = canvas.getContext('2d'); // canvas.getContext() returns null if @@ -30,12 +30,12 @@ const cropImage = ( image, (crop.x || 0) * scaleX, (crop.y || 0) * scaleY, - crop.width * scaleX, - crop.height * scaleY, + canvas.width, + canvas.height, 0, 0, - crop.width, - crop.height, + canvas.width, + canvas.height, ); return new Promise((resolve, reject) => {