diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.ts index 7ab88db..4c16df8 100644 --- a/electron/commands/batch-upscayl.ts +++ b/electron/commands/batch-upscayl.ts @@ -43,8 +43,8 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { const isDefaultModel = DEFAULT_MODELS.includes(model); const scale = payload.scale; - const customWidth = payload.customWidth; const useCustomWidth = payload.useCustomWidth; + const customWidth = useCustomWidth ? payload.customWidth : ""; const outputFolderName = `upscayl_${saveImageAs}_${model}_${scale ? scale : ""}${useCustomWidth ? "px" : "x"}`; @@ -98,6 +98,8 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { logit("❌ ", data); failed = true; upscayl.kill(); + } else if (data.includes("Resizing")) { + mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); } }; const onError = (data: any) => { @@ -123,15 +125,6 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { logit("♻ Scaling and converting now..."); upscayl.kill(); mainWindow && mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); - if (noImageProcessing) { - logit("🚫 Skipping scaling and converting"); - mainWindow.setProgressBar(-1); - mainWindow.webContents.send( - COMMAND.FOLDER_UPSCAYL_DONE, - outputFolderPath, - ); - return; - } try { mainWindow.webContents.send( COMMAND.FOLDER_UPSCAYL_DONE, diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.ts index 9549a2b..7ca4e94 100644 --- a/electron/commands/double-upscayl.ts +++ b/electron/commands/double-upscayl.ts @@ -51,8 +51,8 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { const fileName = parse(fullfileName).name; const scale = parseInt(payload.scale) * parseInt(payload.scale); - const customWidth = payload.customWidth; const useCustomWidth = payload.useCustomWidth; + const customWidth = useCustomWidth ? payload.customWidth : ""; const outFile = outputDir + @@ -78,6 +78,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { gpuId, saveImageAs, scale: scale.toString(), + customWidth, }), logit, ); @@ -86,7 +87,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { setStopped(false); let failed = false; - let isAlpha = false; let failed2 = false; const onData = (data) => { @@ -99,10 +99,12 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { if (data.includes("Error") || data.includes("failed")) { upscayl.kill(); failed = true; + } else if (data.includes("Resizing")) { + mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); } - if (data.includes("alpha channel")) { - isAlpha = true; - } + // if (data.includes("alpha channel")) { + // isAlpha = true; + // } }; const onError = (data) => { @@ -127,20 +129,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { if (!mainWindow) return; if (!failed2 && !stopped) { logit("💯 Done upscaling"); - logit("♻ Scaling and converting now..."); - mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); - if (noImageProcessing) { - logit("🚫 Skipping scaling and converting"); - mainWindow.setProgressBar(-1); - mainWindow.webContents.send( - COMMAND.DOUBLE_UPSCAYL_DONE, - outFile.replace( - /([^/\\]+)$/i, - encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]), - ), - ); - return; - } try { mainWindow.setProgressBar(-1); @@ -174,7 +162,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { // UPSCALE let upscayl2 = spawnUpscayl( getDoubleUpscaleSecondPassArguments({ - isAlpha, outFile, modelsPath: isDefaultModel ? modelsPath diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.ts index 29c4530..13e0b9f 100644 --- a/electron/commands/image-upscayl.ts +++ b/electron/commands/image-upscayl.ts @@ -59,11 +59,9 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { const fileName = parse(fullfileName).name; const fileExt = parse(fullfileName).ext; const useCustomWidth = payload.useCustomWidth; - const customWidth = payload.customWidth; + const customWidth = useCustomWidth ? payload.customWidth : ""; - const desiredScale = useCustomWidth - ? customWidth || payload.scale - : payload.scale; + const desiredScale = payload.scale; const outFile = outputDir + @@ -136,10 +134,11 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { logit("❌ INVALID GPU OR FAILED"); upscayl.kill(); failed = true; - } - if (data.includes("has alpha channel")) { + } else if (data.includes("has alpha channel")) { logit("📢 INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!"); isAlpha = true; + } else if (data.includes("Resizing")) { + mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); } }; const onError = (data) => { @@ -154,19 +153,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { if (!failed && !stopped) { logit("💯 Done upscaling"); logit("♻ Scaling and converting now..."); - if (noImageProcessing) { - logit("🚫 Skipping scaling and converting"); - mainWindow.setProgressBar(-1); - mainWindow.webContents.send( - COMMAND.UPSCAYL_DONE, - outFile.replace( - /([^/\\]+)$/i, - encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]), - ), - ); - return; - } - mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); // Free up memory upscayl.kill(); try { diff --git a/electron/utils/get-arguments.ts b/electron/utils/get-arguments.ts index 002a1b6..43a468c 100644 --- a/electron/utils/get-arguments.ts +++ b/electron/utils/get-arguments.ts @@ -28,14 +28,12 @@ export const getSingleImageArguments = ({ inputDir + slash + fullfileName, "-o", outFile, - "-s", - scale, + customWidth ? "" : `-s ${scale}`, "-m", modelsPath, "-n", model, - gpuId ? "-g" : "", - gpuId ? gpuId : "", + gpuId ? `-g ${gpuId}` : "", "-f", saveImageAs, customWidth ? `-w ${customWidth}` : "", @@ -51,6 +49,7 @@ export const getDoubleUpscaleArguments = ({ gpuId, saveImageAs, scale, + customWidth, }: { inputDir: string; fullfileName: string; @@ -60,59 +59,56 @@ export const getDoubleUpscaleArguments = ({ gpuId: string; saveImageAs: ImageFormat; scale: string; -}) => { - return [ - "-i", - inputDir + slash + fullfileName, - "-o", - outFile, - "-s", - scale, - "-m", - modelsPath, - "-n", - model, - gpuId ? "-g" : "", - gpuId ? gpuId : "", - "-f", - saveImageAs, - ]; -}; - -export const getDoubleUpscaleSecondPassArguments = ({ - isAlpha, - outFile, - modelsPath, - model, - gpuId, - saveImageAs, - scale, - customWidth, -}: { - isAlpha: boolean; - outFile: string; - modelsPath: string; - model: string; - gpuId: string; - saveImageAs: ImageFormat; - scale: string; customWidth: string; }) => { return [ "-i", - isAlpha ? outFile + ".png" : outFile, + inputDir + slash + fullfileName, "-o", - isAlpha ? outFile + ".png" : outFile, - "-s", - scale, + outFile, + customWidth ? "" : `-s ${scale}`, "-m", modelsPath, "-n", model, - gpuId ? "-g" : "", - gpuId ? gpuId : "", - isAlpha ? "" : "-f", - isAlpha ? "" : saveImageAs, + gpuId ? `-g ${gpuId}` : "", + "-f", + saveImageAs, + customWidth ? `-w ${customWidth}` : "", + ]; +}; + +export const getDoubleUpscaleSecondPassArguments = ({ + outFile, + modelsPath, + model, + gpuId, + saveImageAs, + scale, + customWidth, +}: { + outFile: string; + modelsPath: string; + model: string; + gpuId: string; + saveImageAs: ImageFormat; + scale: string; + customWidth: string; +}) => { + return [ + "-i", + outFile, + "-o", + outFile, + "-s", + customWidth ? "" : `-s ${scale}`, + "-m", + modelsPath, + "-n", + model, + gpuId ? `-g ${gpuId}` : "", + "-f", + saveImageAs, customWidth ? `-w ${customWidth}` : "", ]; }; @@ -141,14 +137,12 @@ export const getBatchArguments = ({ inputDir, "-o", outputDir, - "-s", - scale, + customWidth ? "" : `-s ${scale}`, "-m", modelsPath, "-n", model, - gpuId ? "-g" : "", - gpuId ? gpuId : "", + gpuId ? `-g ${gpuId}` : "", "-f", saveImageAs, customWidth ? `-w ${customWidth}` : "", diff --git a/electron/utils/spawn-upscayl.ts b/electron/utils/spawn-upscayl.ts index 034a15d..16d40d6 100644 --- a/electron/utils/spawn-upscayl.ts +++ b/electron/utils/spawn-upscayl.ts @@ -3,11 +3,11 @@ import { execPath } from "./get-resource-paths"; export const spawnUpscayl = ( command: string[], - logit: (...args: any) => void + logit: (...args: any) => void, ) => { logit( "📢 Upscayl Command: ", - command.filter((arg) => arg !== "") + command.filter((arg) => arg !== ""), ); const spawnedProcess = spawn( @@ -16,7 +16,7 @@ export const spawnUpscayl = ( { cwd: undefined, detached: false, - } + }, ); return { diff --git a/renderer/atoms/userSettingsAtom.ts b/renderer/atoms/userSettingsAtom.ts index e179876..b8d6c14 100644 --- a/renderer/atoms/userSettingsAtom.ts +++ b/renderer/atoms/userSettingsAtom.ts @@ -48,10 +48,7 @@ export const viewTypeAtom = atomWithStorage<"slider" | "lens">( export const lensSizeAtom = atomWithStorage("lensSize", 100); -export const customWidthAtom = atomWithStorage( - "customWidth", - null, -); +export const customWidthAtom = atomWithStorage("customWidth", 0); export const useCustomWidthAtom = atomWithStorage( "useCustomWidth", diff --git a/renderer/components/settings-tab/CompressionInput.tsx b/renderer/components/settings-tab/CompressionInput.tsx index bd7027e..f5d392c 100644 --- a/renderer/components/settings-tab/CompressionInput.tsx +++ b/renderer/components/settings-tab/CompressionInput.tsx @@ -14,7 +14,8 @@ export function CompressionInput({ {compression > 0 && (

- PNG compression is not supported at the moment. + PNG compression is lossless. It might not have a significant effect on + some images.

)}
@@ -25,29 +23,26 @@ export function ImageFormatSelect({
{batchMode &&

} - {noImageProcessing && ( -

- {batchMode && "Only PNG is supported in Batch Upscayl."} Only PNGs - are saved without image processing to preserve image quality. -

- )}
{/* PNG */} {/* JPG */} {/* WEBP */}
diff --git a/renderer/components/settings-tab/ImageScaleSelect.tsx b/renderer/components/settings-tab/ImageScaleSelect.tsx index bf7a766..f31d285 100644 --- a/renderer/components/settings-tab/ImageScaleSelect.tsx +++ b/renderer/components/settings-tab/ImageScaleSelect.tsx @@ -20,10 +20,16 @@ export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) { Anything above 4X (except 16X Double Upscayl) only resizes the image and does not use AI upscaling.

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

+ This may cause performance issues on some devices! +

+ )} { setScale(e.target.value.toString()); diff --git a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx index 70bacdb..77dbf6a 100644 --- a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx +++ b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx @@ -10,6 +10,8 @@ import { progressAtom, rememberOutputFolderAtom, scaleAtom, + customWidthAtom, + useCustomWidthAtom, } from "../../../atoms/userSettingsAtom"; import { featureFlags } from "@common/feature-flags"; import getModelScale from "@common/check-model-scale"; @@ -66,6 +68,8 @@ function LeftPaneImageSteps({ const [progress, setProgress] = useAtom(progressAtom); const rememberOutputFolder = useAtomValue(rememberOutputFolderAtom); const [open, setOpen] = React.useState(false); + const [customWidth, setCustomWidth] = useAtom(customWidthAtom); + const [useCustomWidth, setUseCustomWidth] = useAtom(useCustomWidthAtom); const [targetWidth, setTargetWidth] = useState(null); const [targetHeight, setTargetHeight] = useState(null); @@ -143,22 +147,14 @@ function LeftPaneImageSteps({ let doubleScale = parseInt(scale) * parseInt(scale); let singleScale = parseInt(scale); - if (noImageProcessing) { - let initialScale = parseInt(getModelScale(model)); - doubleScale = initialScale * initialScale; - singleScale = initialScale; + if (useCustomWidth) { } if (doubleUpscayl) { const newWidth = dimensions.width * doubleScale; const newHeight = dimensions.height * doubleScale; - if (newWidth < 32768 || newHeight < 32768) { - newDimensions.width = newWidth; - newDimensions.height = newHeight; - } else { - newDimensions.width = 32384; - newDimensions.height = 32384; - } + newDimensions.width = newWidth; + newDimensions.height = newHeight; } else { newDimensions.width = dimensions.width * singleScale; newDimensions.height = dimensions.height * singleScale; @@ -195,11 +191,13 @@ function LeftPaneImageSteps({
{/* STEP 1 */} -
+

Step 1

@@ -255,7 +253,7 @@ function LeftPaneImageSteps({ @@ -264,11 +262,7 @@ function LeftPaneImageSteps({
{/* STEP 3 */} -
+
Step 3 @@ -298,7 +292,12 @@ function LeftPaneImageSteps({ Defaults to {!batchMode ? "Image's" : "Folder's"} path

)} -
@@ -333,7 +332,10 @@ function LeftPaneImageSteps({
- +
); } diff --git a/renderer/components/upscayl-tab/view/ProgressBar.tsx b/renderer/components/upscayl-tab/view/ProgressBar.tsx index 8954b3d..c27aa99 100644 --- a/renderer/components/upscayl-tab/view/ProgressBar.tsx +++ b/renderer/components/upscayl-tab/view/ProgressBar.tsx @@ -24,7 +24,7 @@ function ProgressBar({ return (
-
+
Upscayl Icon Doing the Upscayl magic...

- {batchMode && ( -

- Info: The images will be converted and scaled after the upscaling - process. -

- )} diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index d93d519..108aa87 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -499,8 +499,8 @@ const Home = () => { scale, noImageProcessing, compression: compression.toString(), + customWidth: customWidth > 0 ? customWidth.toString() : null, useCustomWidth, - customWidth: customWidth.toString(), }); logit("🏁 DOUBLE_UPSCAYL"); } else if (batchMode) { @@ -515,7 +515,7 @@ const Home = () => { scale, noImageProcessing, compression: compression.toString(), - customWidth: customWidth.toString(), + customWidth: customWidth > 0 ? customWidth.toString() : null, useCustomWidth, }); logit("🏁 FOLDER_UPSCAYL"); @@ -531,7 +531,7 @@ const Home = () => { overwrite, noImageProcessing, compression: compression.toString(), - customWidth: customWidth.toString(), + customWidth: customWidth > 0 ? customWidth.toString() : null, useCustomWidth, }); logit("🏁 UPSCAYL"); diff --git a/renderer/styles/globals.css b/renderer/styles/globals.css index 7301bf1..e8297f0 100644 --- a/renderer/styles/globals.css +++ b/renderer/styles/globals.css @@ -41,10 +41,73 @@ @layer base { * { - @apply select-none; + @apply select-none border-border; font-family: "Poppins", sans-serif; } + body { + @apply bg-background text-foreground; + } + :root { + --background: 0 0% 100%; + --foreground: 222.2 84% 4.9%; + --card: 0 0% 100%; + --card-foreground: 222.2 84% 4.9%; + + --popover: 0 0% 100%; + --popover-foreground: 222.2 84% 4.9%; + + --primary: 222.2 47.4% 11.2%; + --primary-foreground: 210 40% 98%; + + --secondary: 210 40% 96.1%; + --secondary-foreground: 222.2 47.4% 11.2%; + + --muted: 210 40% 96.1%; + --muted-foreground: 215.4 16.3% 46.9%; + + --accent: 210 40% 96.1%; + --accent-foreground: 222.2 47.4% 11.2%; + + --destructive: 0 84.2% 60.2%; + --destructive-foreground: 210 40% 98%; + + --border: 214.3 31.8% 91.4%; + --input: 214.3 31.8% 91.4%; + --ring: 222.2 84% 4.9%; + + --radius: 0.5rem; + } + + .dark { + --background: 222.2 84% 4.9%; + --foreground: 210 40% 98%; + + --card: 222.2 84% 4.9%; + --card-foreground: 210 40% 98%; + + --popover: 222.2 84% 4.9%; + --popover-foreground: 210 40% 98%; + + --primary: 210 40% 98%; + --primary-foreground: 222.2 47.4% 11.2%; + + --secondary: 217.2 32.6% 17.5%; + --secondary-foreground: 210 40% 98%; + + --muted: 217.2 32.6% 17.5%; + --muted-foreground: 215 20.2% 65.1%; + + --accent: 217.2 32.6% 17.5%; + --accent-foreground: 210 40% 98%; + + --destructive: 0 62.8% 30.6%; + --destructive-foreground: 210 40% 98%; + + --border: 217.2 32.6% 17.5%; + --input: 217.2 32.6% 17.5%; + --ring: 212.7 26.8% 83.9%; + } .hide-scrollbar::-webkit-scrollbar-track { @apply bg-transparent; } @@ -166,6 +229,10 @@ @apply rounded-lg bg-primary p-1 font-medium normal-case; } +.__rcs-handle-button { + @apply border-white; +} + .mac-titlebar { -webkit-app-region: drag; } @@ -237,81 +304,3 @@ -webkit-transform: perspective(120px) rotateX(-360deg) rotateY(-359.9deg); } } - -/* SHADCN CHANGES */ -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 222.2 84% 4.9%; - - --card: 0 0% 100%; - --card-foreground: 222.2 84% 4.9%; - - --popover: 0 0% 100%; - --popover-foreground: 222.2 84% 4.9%; - - --primary: 222.2 47.4% 11.2%; - --primary-foreground: 210 40% 98%; - - --secondary: 210 40% 96.1%; - --secondary-foreground: 222.2 47.4% 11.2%; - - --muted: 210 40% 96.1%; - --muted-foreground: 215.4 16.3% 46.9%; - - --accent: 210 40% 96.1%; - --accent-foreground: 222.2 47.4% 11.2%; - - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 210 40% 98%; - - --border: 214.3 31.8% 91.4%; - --input: 214.3 31.8% 91.4%; - --ring: 222.2 84% 4.9%; - - --radius: 0.5rem; - } - - .dark { - --background: 222.2 84% 4.9%; - --foreground: 210 40% 98%; - - --card: 222.2 84% 4.9%; - --card-foreground: 210 40% 98%; - - --popover: 222.2 84% 4.9%; - --popover-foreground: 210 40% 98%; - - --primary: 210 40% 98%; - --primary-foreground: 222.2 47.4% 11.2%; - - --secondary: 217.2 32.6% 17.5%; - --secondary-foreground: 210 40% 98%; - - --muted: 217.2 32.6% 17.5%; - --muted-foreground: 215 20.2% 65.1%; - - --accent: 217.2 32.6% 17.5%; - --accent-foreground: 210 40% 98%; - - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 40% 98%; - - --border: 217.2 32.6% 17.5%; - --input: 217.2 32.6% 17.5%; - --ring: 212.7 26.8% 83.9%; - } -} - -@layer base { - * { - @apply border-border; - } - body { - @apply bg-background text-foreground; - } -} diff --git a/resources/linux/bin/upscayl-bin b/resources/linux/bin/upscayl-bin index 2c126c9..0d470b5 100755 Binary files a/resources/linux/bin/upscayl-bin and b/resources/linux/bin/upscayl-bin differ diff --git a/resources/mac/bin/upscayl-bin b/resources/mac/bin/upscayl-bin index e69080a..aac0d50 100755 Binary files a/resources/mac/bin/upscayl-bin and b/resources/mac/bin/upscayl-bin differ diff --git a/resources/win/bin/upscayl-bin.exe b/resources/win/bin/upscayl-bin.exe index f21cef3..117c8b1 100644 Binary files a/resources/win/bin/upscayl-bin.exe and b/resources/win/bin/upscayl-bin.exe differ