From d095ded3fff2bb429ad62557c8b7d09ba9e8f974 Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Sun, 21 Apr 2024 23:03:02 +0530 Subject: [PATCH] Fix resolution logic --- electron/utils/get-arguments.ts | 1 - .../upscayl-tab/config/LeftPaneImageSteps.tsx | 29 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/electron/utils/get-arguments.ts b/electron/utils/get-arguments.ts index 43a468c..687c078 100644 --- a/electron/utils/get-arguments.ts +++ b/electron/utils/get-arguments.ts @@ -74,7 +74,6 @@ export const getDoubleUpscaleArguments = ({ gpuId ? `-g ${gpuId}` : "", "-f", saveImageAs, - customWidth ? `-w ${customWidth}` : "", ]; }; diff --git a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx index 778dfb4..b71a754 100644 --- a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx +++ b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx @@ -148,17 +148,28 @@ function LeftPaneImageSteps({ let doubleScale = parseInt(scale) * parseInt(scale); let singleScale = parseInt(scale); - if (useCustomWidth) { - } - if (doubleUpscayl) { - const newWidth = dimensions.width * doubleScale; - const newHeight = dimensions.height * doubleScale; - newDimensions.width = newWidth; - newDimensions.height = newHeight; + if (useCustomWidth) { + newDimensions.width = customWidth; + newDimensions.height = Math.round( + customWidth * (dimensions.height / dimensions.width), + ); + } else { + const newWidth = dimensions.width * doubleScale; + const newHeight = dimensions.height * doubleScale; + newDimensions.width = newWidth; + newDimensions.height = newHeight; + } } else { - newDimensions.width = dimensions.width * singleScale; - newDimensions.height = dimensions.height * singleScale; + if (useCustomWidth) { + newDimensions.width = customWidth; + newDimensions.height = Math.round( + customWidth * (dimensions.height / dimensions.width), + ); + } else { + newDimensions.width = dimensions.width * singleScale; + newDimensions.height = dimensions.height * singleScale; + } } return newDimensions;