From bc63f8533e3fb359e13f5e50a14d2cf6a4acbec5 Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:57:16 +0530 Subject: [PATCH] Add scale on main screen --- renderer/atoms/userSettingsAtom.ts | 2 +- .../settings-tab/CompressionInput.tsx | 4 +- .../settings-tab/ImageScaleSelect.tsx | 51 +++++++++++++----- .../upscayl-tab/config/LeftPaneImageSteps.tsx | 53 ++++++++++--------- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/renderer/atoms/userSettingsAtom.ts b/renderer/atoms/userSettingsAtom.ts index b8d6c14..e3aacd9 100644 --- a/renderer/atoms/userSettingsAtom.ts +++ b/renderer/atoms/userSettingsAtom.ts @@ -6,7 +6,7 @@ export const customModelsPathAtom = atomWithStorage( null, ); -export const scaleAtom = atomWithStorage<"2" | "3" | "4">("scale", "4"); +export const scaleAtom = atomWithStorage("scale", "4"); export const batchModeAtom = atom(false); diff --git a/renderer/components/settings-tab/CompressionInput.tsx b/renderer/components/settings-tab/CompressionInput.tsx index f5d392c..e50d442 100644 --- a/renderer/components/settings-tab/CompressionInput.tsx +++ b/renderer/components/settings-tab/CompressionInput.tsx @@ -14,8 +14,8 @@ export function CompressionInput({ {compression > 0 && (

- PNG compression is lossless. It might not have a significant effect on - some images. + PNG compression is lossless, so it might not reduce the file size + significantly. JPG and WebP compression is lossy.

)} void; + scale: string; + setScale: React.Dispatch>; + hideInfo?: boolean; }; -export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) { - const [useCustomWidth, setUseCustomWidth] = useAtom(useCustomWidthAtom); +export function ImageScaleSelect({ + scale, + setScale, + hideInfo, +}: ImageScaleSelectProps) { + const useCustomWidth = useAtomValue(useCustomWidthAtom); return (
-

- IMAGE SCALE ({scale}X) {useCustomWidth && "DISABLED"} -

+ {hideInfo ? ( + <> +

+ Image Scale ({scale}X) +

+ {hideInfo && parseInt(scale) >= 6 && ( +

+ ! +

+ )} + + ) : ( +

+ IMAGE SCALE ({scale}X) {useCustomWidth && "DISABLED"} +

+ )}
-

- Anything above 4X (except 16X Double Upscayl) only resizes the image and - does not use AI upscaling. -

- {parseInt(scale) >= 6 && ( + {!hideInfo && ( +

+ Anything above 4X (except 16X Double Upscayl) only resizes the image + and does not use AI upscaling. +

+ )} + {!hideInfo && parseInt(scale) >= 6 && (

This may cause performance issues on some devices!

)} + Promise; @@ -62,7 +63,7 @@ function LeftPaneImageSteps({ }); const modelOptions = useAtomValue(modelsListAtom); - const scale = useAtomValue(scaleAtom); + const [scale, setScale] = useAtom(scaleAtom); const noImageProcessing = useAtomValue(noImageProcessingAtom); const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom); const [progress, setProgress] = useAtom(progressAtom); @@ -204,32 +205,34 @@ function LeftPaneImageSteps({
{/* STEP 2 */} -
-

Step 2

-

Select Model

+
+
+

Step 2

+

Select Model

- setOpen(true)} + onMenuClose={() => setOpen(false)} + options={modelOptions} + components={{ + IndicatorSeparator: () => null, + DropdownIndicator: () => null, + }} + onChange={(e) => { + handleModelChange(e); + setCurrentModel({ label: e.label, value: e.value }); + }} + className={cn( + "react-select-container transition-all group-hover:w-full group-active:w-full focus:w-full", + open && "!w-full", + )} + classNamePrefix="react-select" + value={currentModel} + /> +
{!batchMode && ( -
+
)} + +
{/* STEP 3 */}