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 ( -
+

If you like what we do :)

- - + + Donate
); diff --git a/renderer/components/settings-tab/ImageScaleSelect.tsx b/renderer/components/settings-tab/ImageScaleSelect.tsx index 2a0f8b6..c4f7f17 100644 --- a/renderer/components/settings-tab/ImageScaleSelect.tsx +++ b/renderer/components/settings-tab/ImageScaleSelect.tsx @@ -20,7 +20,7 @@ export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) {
{ @@ -30,22 +30,11 @@ export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) { className="range range-primary mt-2" />
+ 1x 2x 3x 4x
- {scale !== "4" && ( -

- This may generate unexpected output! -
- - See Wiki - -

- )} ); } diff --git a/renderer/components/settings-tab/index.tsx b/renderer/components/settings-tab/index.tsx index 824ffc1..3817d0c 100644 --- a/renderer/components/settings-tab/index.tsx +++ b/renderer/components/settings-tab/index.tsx @@ -128,12 +128,16 @@ function SettingsTab({ return (
- - Read WIKI - +
+

Having issues?

+ + Read Wiki Guide + + +
{/* THEME SELECTOR */} @@ -167,9 +171,6 @@ function SettingsTab({ isCopied={isCopied} logData={logData} /> - - {/* DONATE BUTTON */} -
); }