From 269d5d960368b2bf1727a638e97ec51b43a4cb14 Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Sun, 23 Jul 2023 12:02:22 +0530 Subject: [PATCH] Fix scale slider --- electron/index.ts | 31 ++++++++++++------- .../components/settings-tab/DonateButton.tsx | 9 ++++-- .../settings-tab/ImageScaleSelect.tsx | 15 ++------- renderer/components/settings-tab/index.tsx | 19 ++++++------ 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/electron/index.ts b/electron/index.ts index 3e0a5b2..e64c761 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -565,28 +565,35 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => { failed = true; return; }; - const onClose = () => { + const onClose = async () => { if (!failed && !stopped) { logit("💯 Done upscaling"); logit("♻ Scaling and converting now..."); - Jimp.read( - isAlpha ? outFile + ".png" : outFile, - (err: any, image: any) => { - if (err) { - logit("❌ Error converting to PNG: ", err); - onError(err); - return; - } - image - .scale(parseInt(payload.scale as string)) + const originalImage = await Jimp.read(inputDir + slash + fullfileName); + try { + const newImage = await Jimp.read( + isAlpha ? outFile + ".png" : outFile + ); + try { + newImage + .scaleToFit( + originalImage.getWidth() * parseInt(payload.scale), + originalImage.getHeight() * parseInt(payload.scale) + ) .write(isAlpha ? outFile + ".png" : outFile); mainWindow.setProgressBar(-1); mainWindow.webContents.send( commands.UPSCAYL_DONE, isAlpha ? outFile + ".png" : outFile ); + } catch (error) { + logit("❌ Error converting to PNG: ", error); + onError(error); } - ); + } catch (error) { + logit("❌ Error reading original image metadata", error); + onError(error); + } } }; diff --git a/renderer/components/settings-tab/DonateButton.tsx b/renderer/components/settings-tab/DonateButton.tsx index b945ea0..a56dd00 100644 --- a/renderer/components/settings-tab/DonateButton.tsx +++ b/renderer/components/settings-tab/DonateButton.tsx @@ -1,10 +1,13 @@ import React from "react"; export function DonateButton({}) { return ( -
- This may generate unexpected output!
-
-
- See Wiki
-
-