From 23127318dcd9b99e38f7736c09e95672d02e0d6d Mon Sep 17 00:00:00 2001 From: Bill Gale Date: Tue, 7 Dec 2021 17:05:26 +0000 Subject: [PATCH] fix: prevent image uploader converting every image to jpeg (#1262) --- components/ImageUploader.tsx | 4 ++-- lib/cropImage.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/ImageUploader.tsx b/components/ImageUploader.tsx index aa6d89ad5f..6ed211e6fb 100644 --- a/components/ImageUploader.tsx +++ b/components/ImageUploader.tsx @@ -125,9 +125,9 @@ export default function ImageUploader({
-
+
{!result && ( -
+
{!imageSrc && (

{t("no_target", { target })} diff --git a/lib/cropImage.ts b/lib/cropImage.ts index 1efedc0e5a..45a39ea487 100644 --- a/lib/cropImage.ts +++ b/lib/cropImage.ts @@ -45,7 +45,7 @@ export async function getCroppedImg(imageSrc: string, pixelCrop: Area): Promise< // on very low ratios, the quality of the resize becomes awful. For this reason the resizeRatio is limited to 0.75 if (resizeRatio <= 0.75) { // With a smaller image, thus improved ratio. Keep doing this until the resizeRatio > 0.75. - return getCroppedImg(canvas.toDataURL("image/jpeg"), { + return getCroppedImg(canvas.toDataURL("image/png"), { width: canvas.width, height: canvas.height, x: 0, @@ -53,5 +53,5 @@ export async function getCroppedImg(imageSrc: string, pixelCrop: Area): Promise< }); } - return canvas.toDataURL("image/jpeg"); + return canvas.toDataURL("image/png"); }