Skip to content

πŸ†™ Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.

Fix scale and config vars

Nayam Amarshe0fe8bf8ba4d3
diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.ts
index dce03b3..bd2864f 100644
--- a/electron/commands/batch-upscayl.ts
+++ b/electron/commands/batch-upscayl.ts
@@ -2,10 +2,10 @@ import fs from "fs";
import { getMainWindow } from "../main-window";
import {
childProcesses,
- customModelsFolderPath,
+ savedCustomModelsPath,
customWidth,
noImageProcessing,
- saveOutputFolder,
+ rememberOutputFolder,
setCompression,
setNoImageProcessing,
setStopped,
@@ -37,7 +37,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
let inputDir = payload.batchFolderPath;
// GET THE OUTPUT DIRECTORY
let outputFolderPath = payload.outputPath;
- if (saveOutputFolder === true && outputFolderPath) {
+ if (rememberOutputFolder === true && outputFolderPath) {
outputFolderPath = outputFolderPath;
}
// ! Don't do fetchLocalStorage() again, it causes the values to be reset
@@ -46,13 +46,9 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
const isDefaultModel = DEFAULT_MODELS.includes(model);
- let initialScale = getModelScale(model);
+ const scale = payload.scale;
- const desiredScale = useCustomWidth
- ? customWidth || payload.scale
- : payload.scale;
-
- const outputFolderName = `upscayl_${saveImageAs}_${model}_${noImageProcessing ? initialScale : desiredScale}${useCustomWidth ? "px" : "x"}`;
+ const outputFolderName = `upscayl_${saveImageAs}_${model}_${scale}${useCustomWidth ? "px" : "x"}`;
outputFolderPath += slash + outputFolderName;
if (!fs.existsSync(outputFolderPath)) {
fs.mkdirSync(outputFolderPath, { recursive: true });
@@ -72,15 +68,17 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
// UPSCALE
const upscayl = spawnUpscayl(
- getBatchArguments(
+ getBatchArguments({
inputDir,
- outputFolderPath,
- isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
+ outputDir: outputFolderPath,
+ modelsPath: isDefaultModel
+ ? modelsPath
+ : savedCustomModelsPath ?? modelsPath,
model,
gpuId,
saveImageAs,
- initialScale,
- ),
+ scale,
+ }),
logit,
);
diff --git a/electron/commands/custom-models-select.ts b/electron/commands/custom-models-select.ts
index 8fe6d2e..bd2edd5 100644
--- a/electron/commands/custom-models-select.ts
+++ b/electron/commands/custom-models-select.ts
@@ -1,7 +1,7 @@
import { MessageBoxOptions, dialog } from "electron";
import {
- customModelsFolderPath,
- setCustomModelsFolderPath,
+ savedCustomModelsPath,
+ setSavedCustomModelsPath,
} from "../utils/config-variables";
import logit from "../utils/logit";
import slash from "../utils/slash";
@@ -22,7 +22,7 @@ const customModelsSelect = async (event, message) => {
} = await dialog.showOpenDialog({
properties: ["openDirectory"],
title: "Select Custom Models Folder",
- defaultPath: customModelsFolderPath,
+ defaultPath: savedCustomModelsPath,
securityScopedBookmarks: true,
message: "Select Custom Models Folder that is named 'models'",
});
@@ -36,7 +36,7 @@ const customModelsSelect = async (event, message) => {
logit("🚫 Select Custom Models Folder Operation Cancelled");
return null;
} else {
- setCustomModelsFolderPath(folderPaths[0]);
+ setSavedCustomModelsPath(folderPaths[0]);
if (
!folderPaths[0].endsWith(slash + "models") &&
@@ -54,11 +54,11 @@ const customModelsSelect = async (event, message) => {
return null;
}
- const models = await getModels(customModelsFolderPath);
+ const models = await getModels(savedCustomModelsPath);
mainWindow.webContents.send(COMMAND.CUSTOM_MODEL_FILES_LIST, models);
- logit("πŸ“ Custom Folder Path: ", customModelsFolderPath);
- return customModelsFolderPath;
+ logit("πŸ“ Custom Folder Path: ", savedCustomModelsPath);
+ return savedCustomModelsPath;
}
};
diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.ts
index 803f712..e3703e7 100644
--- a/electron/commands/double-upscayl.ts
+++ b/electron/commands/double-upscayl.ts
@@ -2,12 +2,12 @@ import path, { parse } from "path";
import { getMainWindow } from "../main-window";
import {
childProcesses,
- customModelsFolderPath,
+ savedCustomModelsPath,
customWidth,
- folderPath,
+ savedBatchUpscaylFolderPath,
noImageProcessing,
- outputFolderPath,
- saveOutputFolder,
+ savedOutputPath,
+ rememberOutputFolder,
setCompression,
setNoImageProcessing,
setStopped,
@@ -39,8 +39,8 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
let inputDir = (imagePath.match(/(.*)[\/\\]/) || [""])[1];
let outputDir = path.normalize(payload.outputPath);
- if (saveOutputFolder === true && outputFolderPath) {
- outputDir = outputFolderPath;
+ if (rememberOutputFolder === true && savedOutputPath) {
+ outputDir = savedOutputPath;
}
const gpuId = payload.gpuId as string;
const saveImageAs = payload.saveImageAs as ImageFormat;
@@ -55,20 +55,14 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
const fullfileName = imagePath.split(slash).slice(-1)[0] as string;
const fileName = parse(fullfileName).name;
- let initialScale = getModelScale(model);
-
- const desiredScale = useCustomWidth
- ? customWidth || parseInt(payload.scale) * parseInt(payload.scale)
- : parseInt(payload.scale) * parseInt(payload.scale);
+ const scale = parseInt(payload.scale) * parseInt(payload.scale);
const outFile =
outputDir +
slash +
fileName +
"_upscayl_" +
- (noImageProcessing
- ? parseInt(initialScale) * parseInt(initialScale)
- : desiredScale) +
+ scale +
(useCustomWidth ? "px_" : "x_") +
model +
"." +
@@ -76,16 +70,18 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
// UPSCALE
let upscayl = spawnUpscayl(
- getDoubleUpscaleArguments(
+ getDoubleUpscaleArguments({
inputDir,
fullfileName,
outFile,
- isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
+ modelsPath: isDefaultModel
+ ? modelsPath
+ : savedCustomModelsPath ?? modelsPath,
model,
gpuId,
saveImageAs,
- initialScale,
- ),
+ scale: scale.toString(),
+ }),
logit,
);
@@ -180,15 +176,17 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
if (!failed && !stopped) {
// UPSCALE
let upscayl2 = spawnUpscayl(
- getDoubleUpscaleSecondPassArguments(
+ getDoubleUpscaleSecondPassArguments({
isAlpha,
outFile,
- isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
+ modelsPath: isDefaultModel
+ ? modelsPath
+ : savedCustomModelsPath ?? modelsPath,
model,
gpuId,
saveImageAs,
- initialScale,
- ),
+ scale: scale.toString(),
+ }),
logit,
);
diff --git a/electron/commands/get-models-list.ts b/electron/commands/get-models-list.ts
index 7d19115..dd53bdf 100644
--- a/electron/commands/get-models-list.ts
+++ b/electron/commands/get-models-list.ts
@@ -1,8 +1,8 @@
import COMMAND from "../../common/commands";
import { getMainWindow } from "../main-window";
import {
- customModelsFolderPath,
- setCustomModelsFolderPath,
+ savedCustomModelsPath,
+ setSavedCustomModelsPath,
} from "../utils/config-variables";
import getModels from "../utils/get-models";
import logit from "../utils/logit";
@@ -12,9 +12,9 @@ const getModelsList = async (event, payload) => {
if (!mainWindow) return;
if (payload) {
- setCustomModelsFolderPath(payload);
+ setSavedCustomModelsPath(payload);
- logit("πŸ“ Custom Models Folder Path: ", customModelsFolderPath);
+ logit("πŸ“ Custom Models Folder Path: ", savedCustomModelsPath);
const models = await getModels(payload);
mainWindow.webContents.send(COMMAND.CUSTOM_MODEL_FILES_LIST, models);
diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.ts
index 2dd703f..54c72d2 100644
--- a/electron/commands/image-upscayl.ts
+++ b/electron/commands/image-upscayl.ts
@@ -2,13 +2,13 @@ import fs from "fs";
import { modelsPath } from "../utils/get-resource-paths";
import COMMAND from "../../common/commands";
import {
- compression,
- customModelsFolderPath,
+ savedCompression,
+ savedCustomModelsPath,
customWidth,
- folderPath,
+ savedBatchUpscaylFolderPath,
noImageProcessing,
- outputFolderPath,
- saveOutputFolder,
+ savedOutputPath,
+ rememberOutputFolder,
setChildProcesses,
setCompression,
setNoImageProcessing,
@@ -25,7 +25,6 @@ import { getMainWindow } from "../main-window";
import { ImageUpscaylPayload } from "../../common/types/types";
import { ImageFormat } from "../utils/types";
import getModelScale from "../../common/check-model-scale";
-import removeFileExtension from "../utils/remove-file-extension";
import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
@@ -40,29 +39,27 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
setNoImageProcessing(payload.noImageProcessing);
setCompression(parseInt(payload.compression));
+ // GET VARIABLES
const model = payload.model as string;
const gpuId = payload.gpuId as string;
const saveImageAs = payload.saveImageAs as ImageFormat;
- console.log("πŸš€ => saveImageAs:", saveImageAs);
-
const overwrite = payload.overwrite as boolean;
-
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)?.[1] || "") as string;
let outputDir: string | undefined =
- folderPath || (payload.outputPath as string);
-
- if (saveOutputFolder === true && outputFolderPath) {
- outputDir = outputFolderPath;
+ savedBatchUpscaylFolderPath || (payload.outputPath as string);
+ if (
+ rememberOutputFolder === true &&
+ savedOutputPath &&
+ savedOutputPath?.length > 0
+ ) {
+ logit("🧠 Using saved output path");
+ outputDir = savedOutputPath;
}
-
const isDefaultModel = DEFAULT_MODELS.includes(model);
logit("Is Default Model? : ", isDefaultModel);
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string;
const fileName = parse(fullfileName).name;
const fileExt = parse(fullfileName).ext;
-
- let initialScale = getModelScale(model);
-
const desiredScale = useCustomWidth
? customWidth || payload.scale
: payload.scale;
@@ -72,7 +69,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
slash +
fileName +
"_upscayl_" +
- (noImageProcessing ? initialScale : desiredScale) +
+ desiredScale +
(useCustomWidth ? "px_" : "x_") +
model +
"." +
@@ -100,23 +97,25 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
outputDir,
fullfileName,
fileName,
- initialScale: initialScale,
+ scale: desiredScale,
desiredScale,
outFile,
- compression,
+ compression: savedCompression,
}),
);
const upscayl = spawnUpscayl(
- getSingleImageArguments(
+ getSingleImageArguments({
inputDir,
fullfileName,
outFile,
- isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
+ modelsPath: isDefaultModel
+ ? modelsPath
+ : savedCustomModelsPath ?? modelsPath,
model,
- initialScale,
+ scale: desiredScale,
gpuId,
saveImageAs,
- ),
+ }),
logit,
);
diff --git a/electron/commands/select-file.ts b/electron/commands/select-file.ts
index ec9b813..50bd72c 100644
--- a/electron/commands/select-file.ts
+++ b/electron/commands/select-file.ts
@@ -1,6 +1,6 @@
import { MessageBoxOptions, app, dialog } from "electron";
import { getMainWindow } from "../main-window";
-import { imagePath, setImagePath } from "../utils/config-variables";
+import { savedImagePath, setSavedImagePath } from "../utils/config-variables";
import logit from "../utils/logit";
import settings from "electron-settings";
import { featureFlags } from "../../common/feature-flags";
@@ -11,7 +11,7 @@ const selectFile = async () => {
const { canceled, filePaths, bookmarks } = await dialog.showOpenDialog({
properties: ["openFile"],
title: "Select Image",
- defaultPath: imagePath,
+ defaultPath: savedImagePath,
securityScopedBookmarks: true,
message: "Select Image to Upscale",
filters: [
@@ -40,7 +40,7 @@ const selectFile = async () => {
logit("🚫 File Operation Cancelled");
return null;
} else {
- setImagePath(filePaths[0]);
+ setSavedImagePath(filePaths[0]);
let isValid = false;
// READ SELECTED FILES
diff --git a/electron/commands/select-folder.ts b/electron/commands/select-folder.ts
index ded1f04..96bb77f 100644
--- a/electron/commands/select-folder.ts
+++ b/electron/commands/select-folder.ts
@@ -1,5 +1,8 @@
import { app, dialog } from "electron";
-import { folderPath, setFolderPath } from "../utils/config-variables";
+import {
+ savedBatchUpscaylFolderPath,
+ setSavedBatchUpscaylFolderPath,
+} from "../utils/config-variables";
import logit from "../utils/logit";
import settings from "electron-settings";
import { featureFlags } from "../../common/feature-flags";
@@ -11,7 +14,7 @@ const selectFolder = async (event, message) => {
logit("🚨 Folder Bookmarks: ", folderBookmarks);
try {
closeAccess = app.startAccessingSecurityScopedResource(
- folderBookmarks as string
+ folderBookmarks as string,
);
} catch (error) {
logit("πŸ“ Folder Bookmarks Error: ", error);
@@ -24,7 +27,7 @@ const selectFolder = async (event, message) => {
bookmarks,
} = await dialog.showOpenDialog({
properties: ["openDirectory"],
- defaultPath: folderPath,
+ defaultPath: savedBatchUpscaylFolderPath,
securityScopedBookmarks: true,
});
@@ -37,8 +40,8 @@ const selectFolder = async (event, message) => {
logit("🚫 Select Folder Operation Cancelled");
return null;
} else {
- setFolderPath(folderPaths[0]);
- logit("πŸ“ Selected Folder Path: ", folderPath);
+ setSavedBatchUpscaylFolderPath(folderPaths[0]);
+ logit("πŸ“ Selected Folder Path: ", savedBatchUpscaylFolderPath);
return folderPaths[0];
}
};
diff --git a/electron/utils/config-variables.ts b/electron/utils/config-variables.ts
index 00da749..a56fb12 100644
--- a/electron/utils/config-variables.ts
+++ b/electron/utils/config-variables.ts
@@ -2,92 +2,101 @@ import { ChildProcessWithoutNullStreams } from "child_process";
import { getMainWindow } from "../main-window";
import logit from "./logit";
-export let imagePath: string | undefined = "";
-export let folderPath: string | undefined = undefined;
-export let customModelsFolderPath: string | undefined = undefined;
-export let outputFolderPath: string | undefined = undefined;
-export let saveOutputFolder = false;
-export let compression = 0;
-export let stopped = false;
-export let childProcesses: {
- process: ChildProcessWithoutNullStreams;
- kill: () => boolean;
-}[] = [];
-export let noImageProcessing: boolean = false;
-export let turnOffNotifications: boolean = false;
-export let customWidth: string | null = null;
-export let useCustomWidth: boolean = false;
-
-export function setImagePath(value: string | undefined): void {
- imagePath = value;
- logit("πŸ–ΌοΈ Updating Image Path: ", imagePath);
+/**
+ * The saved image path so that the select image dialog can open to the last used path.
+ */
+export let savedImagePath: string | undefined = "";
+export function setSavedImagePath(value: string | undefined): void {
+ savedImagePath = value;
+ logit("πŸ–ΌοΈ Updating Image Path: ", savedImagePath);
}
-export function setFolderPath(value: string | undefined): void {
- folderPath = value;
- logit("πŸ“ Updating Folder Path: ", folderPath);
+/**
+ * The saved folder path so that the select folder to upscayl dialog can open to the last used path.
+ */
+export let savedBatchUpscaylFolderPath: string | undefined = undefined;
+export function setSavedBatchUpscaylFolderPath(
+ value: string | undefined,
+): void {
+ savedBatchUpscaylFolderPath = value;
+ logit("πŸ“ Updating Folder Path: ", savedBatchUpscaylFolderPath);
}
-export function setCustomModelsFolderPath(value: string | undefined): void {
- customModelsFolderPath = value;
- logit("πŸ“ Updating Custom Models Folder Path: ", customModelsFolderPath);
+export let savedCustomModelsPath: string | undefined = undefined;
+export function setSavedCustomModelsPath(value: string | undefined): void {
+ savedCustomModelsPath = value;
+ logit("πŸ“ Updating Custom Models Folder Path: ", savedCustomModelsPath);
}
-// SETTERS
-export function setOutputFolderPath(value: string | undefined): void {
- outputFolderPath = value;
- logit("πŸ“ Updating Output Folder Path: ", outputFolderPath);
+export let savedOutputPath: string | undefined = undefined;
+export function setSavedOutputPath(value: string | undefined): void {
+ savedOutputPath = value;
+ logit("πŸ“ Updating Output Folder Path: ", savedOutputPath);
}
-export function setSaveOutputFolder(value: boolean): void {
- saveOutputFolder = value;
- logit("πŸ’Ύ Updating Save Output Folder: ", saveOutputFolder);
+export let rememberOutputFolder = false;
+export function setRememberOutputFolder(value: boolean): void {
+ rememberOutputFolder = value;
+ logit("πŸ’Ύ Updating Remember Output Folder: ", rememberOutputFolder);
}
+export let savedCompression = 0;
export function setCompression(value: number): void {
- compression = value;
- logit("πŸ“ Updating Compression: ", compression);
-}
-
-export function setStopped(value: boolean): void {
- stopped = value;
- logit("πŸ›‘ Updating Stopped: ", stopped);
+ savedCompression = value;
+ logit("πŸ“ Updating Compression: ", savedCompression);
}
-export function setChildProcesses(value: {
+export let stopped = false;
+export let childProcesses: {
process: ChildProcessWithoutNullStreams;
kill: () => boolean;
-}): void {
- childProcesses.push(value);
- logit(
- "πŸ‘Ά Updating Child Processes: ",
- JSON.stringify({
- binary: childProcesses[0].process.spawnfile,
- args: childProcesses[0].process.spawnargs,
- }),
- );
-}
+}[] = [];
+export let noImageProcessing: boolean = false;
export function setNoImageProcessing(value: boolean): void {
noImageProcessing = value;
logit("πŸ–ΌοΈ Updating No Image Processing: ", noImageProcessing);
}
+export let turnOffNotifications: boolean = false;
export function setTurnOffNotifications(value: boolean): void {
turnOffNotifications = value;
logit("πŸ”• Updating Turn Off Notifications: ", turnOffNotifications);
}
+export let customWidth: string | null = null;
export function setCustomWidth(value: string | null): void {
customWidth = value;
logit("πŸ“ Updating Custom Width: ", customWidth);
}
+export let useCustomWidth: boolean = false;
export function setUseCustomWidth(value: boolean): void {
useCustomWidth = value;
logit("πŸ“ Updating Use Custom Width: ", useCustomWidth);
}
+// SETTERS
+
+export function setStopped(value: boolean): void {
+ stopped = value;
+ logit("πŸ›‘ Updating Stopped: ", stopped);
+}
+
+export function setChildProcesses(value: {
+ process: ChildProcessWithoutNullStreams;
+ kill: () => boolean;
+}): void {
+ childProcesses.push(value);
+ logit(
+ "πŸ‘Ά Updating Child Processes: ",
+ JSON.stringify({
+ binary: childProcesses[0].process.spawnfile,
+ args: childProcesses[0].process.spawnargs,
+ }),
+ );
+}
+
// LOCAL STORAGE
export function fetchLocalStorage(): void {
const mainWindow = getMainWindow();
@@ -98,34 +107,37 @@ export function fetchLocalStorage(): void {
.executeJavaScript('localStorage.getItem("lastImagePath");', true)
.then((lastImagePath: string | null) => {
if (lastImagePath && lastImagePath.length > 0) {
- setImagePath(lastImagePath);
+ setSavedImagePath(lastImagePath);
}
});
// GET LAST FOLDER PATH TO LOCAL STORAGE
mainWindow.webContents
- .executeJavaScript('localStorage.getItem("lastFolderPath");', true)
- .then((lastFolderPath: string | null) => {
- if (lastFolderPath && lastFolderPath.length > 0) {
- setFolderPath(lastFolderPath);
+ .executeJavaScript(
+ 'localStorage.getItem("lastSavedBatchUpscaylFolderPath");',
+ true,
+ )
+ .then((lastSavedBatchUpscaylFolderPath: string | null) => {
+ if (
+ lastSavedBatchUpscaylFolderPath &&
+ lastSavedBatchUpscaylFolderPath.length > 0
+ ) {
+ setSavedBatchUpscaylFolderPath(lastSavedBatchUpscaylFolderPath);
}
});
// GET LAST CUSTOM MODELS FOLDER PATH TO LOCAL STORAGE
mainWindow.webContents
- .executeJavaScript(
- 'localStorage.getItem("lastCustomModelsFolderPath");',
- true,
- )
- .then((lastCustomModelsFolderPath: string | null) => {
- if (lastCustomModelsFolderPath && lastCustomModelsFolderPath.length > 0) {
- setCustomModelsFolderPath(lastCustomModelsFolderPath);
+ .executeJavaScript('localStorage.getItem("customModelsFolderPath");', true)
+ .then((value: string | null) => {
+ if (value && value.length > 0) {
+ setSavedCustomModelsPath(value);
}
});
// GET LAST CUSTOM MODELS FOLDER PATH TO LOCAL STORAGE
mainWindow.webContents
- .executeJavaScript('localStorage.getItem("lastOutputFolderPath");', true)
- .then((lastOutputFolderPath: string | null) => {
- if (lastOutputFolderPath && lastOutputFolderPath.length > 0) {
- setOutputFolderPath(lastOutputFolderPath);
+ .executeJavaScript('localStorage.getItem("savedOutputPath");', true)
+ .then((savedOutputPath: string | null) => {
+ if (savedOutputPath && savedOutputPath.length > 0) {
+ setSavedOutputPath(savedOutputPath);
}
});
// GET LAST SAVE OUTPUT FOLDER (BOOLEAN) TO LOCAL STORAGE
@@ -133,7 +145,7 @@ export function fetchLocalStorage(): void {
.executeJavaScript('localStorage.getItem("rememberOutputFolder");', true)
.then((lastSaveOutputFolder: boolean | null) => {
if (lastSaveOutputFolder !== null) {
- setSaveOutputFolder(lastSaveOutputFolder);
+ setRememberOutputFolder(lastSaveOutputFolder);
}
});
// GET IMAGE COMPRESSION (NUMBER) FROM LOCAL STORAGE
diff --git a/electron/utils/get-arguments.ts b/electron/utils/get-arguments.ts
index 8f4e1f1..e4dce09 100644
--- a/electron/utils/get-arguments.ts
+++ b/electron/utils/get-arguments.ts
@@ -2,16 +2,25 @@ import { getPlatform } from "./get-device-specs";
import { ImageFormat } from "./types";
const slash: string = getPlatform() === "win" ? "\\" : "/";
-export const getSingleImageArguments = (
- inputDir: string,
- fullfileName: string,
- outFile: string,
- modelsPath: string,
- model: string,
- scale: any,
- gpuId: string,
- saveImageAs: ImageFormat,
-) => {
+export const getSingleImageArguments = ({
+ inputDir,
+ fullfileName,
+ outFile,
+ modelsPath,
+ model,
+ scale,
+ gpuId,
+ saveImageAs,
+}: {
+ inputDir: string;
+ fullfileName: string;
+ outFile: string;
+ modelsPath: string;
+ model: string;
+ scale: any;
+ gpuId: string;
+ saveImageAs: ImageFormat;
+}) => {
return [
"-i",
inputDir + slash + fullfileName,
@@ -30,43 +39,25 @@ export const getSingleImageArguments = (
];
};
-export const getSingleImageSharpenArguments = (
- inputDir: string,
- fullfileName: string,
- outFile: string,
- modelsPath: string,
- model: string,
- scale: any,
- gpuId: string,
- saveImageAs: ImageFormat,
-) => {
- return [
- "-i",
- inputDir + slash + fullfileName,
- "-o",
- outFile,
- "-s",
- scale,
- "-x",
- "-m",
- modelsPath + slash + model,
- gpuId ? "-g" : "",
- gpuId ? gpuId : "",
- "-f",
- saveImageAs,
- ];
-};
-
-export const getDoubleUpscaleArguments = (
- inputDir: string,
- fullfileName: string,
- outFile: string,
- modelsPath: string,
- model: string,
- gpuId: string,
- saveImageAs: ImageFormat,
- scale: string,
-) => {
+export const getDoubleUpscaleArguments = ({
+ inputDir,
+ fullfileName,
+ outFile,
+ modelsPath,
+ model,
+ gpuId,
+ saveImageAs,
+ scale,
+}: {
+ inputDir: string;
+ fullfileName: string;
+ outFile: string;
+ modelsPath: string;
+ model: string;
+ gpuId: string;
+ saveImageAs: ImageFormat;
+ scale: string;
+}) => {
return [
"-i",
inputDir + slash + fullfileName,
@@ -85,15 +76,23 @@ export const getDoubleUpscaleArguments = (
];
};
-export const getDoubleUpscaleSecondPassArguments = (
- isAlpha: boolean,
- outFile: string,
- modelsPath: string,
- model: string,
- gpuId: string,
- saveImageAs: ImageFormat,
- scale: string,
-) => {
+export const getDoubleUpscaleSecondPassArguments = ({
+ isAlpha,
+ outFile,
+ modelsPath,
+ model,
+ gpuId,
+ saveImageAs,
+ scale,
+}: {
+ isAlpha: boolean;
+ outFile: string;
+ modelsPath: string;
+ model: string;
+ gpuId: string;
+ saveImageAs: ImageFormat;
+ scale: string;
+}) => {
return [
"-i",
isAlpha ? outFile + ".png" : outFile,
@@ -112,15 +111,23 @@ export const getDoubleUpscaleSecondPassArguments = (
];
};
-export const getBatchArguments = (
- inputDir: string,
- outputDir: string,
- modelsPath: string,
- model: string,
- gpuId: string,
- saveImageAs: ImageFormat,
- scale: string,
-) => {
+export const getBatchArguments = ({
+ inputDir,
+ outputDir,
+ modelsPath,
+ model,
+ gpuId,
+ saveImageAs,
+ scale,
+}: {
+ inputDir: string;
+ outputDir: string;
+ modelsPath: string;
+ model: string;
+ gpuId: string;
+ saveImageAs: ImageFormat;
+ scale: string;
+}) => {
return [
"-i",
inputDir,
diff --git a/renderer/atoms/userSettingsAtom.ts b/renderer/atoms/userSettingsAtom.ts
index a9070e7..80b0ed5 100644
--- a/renderer/atoms/userSettingsAtom.ts
+++ b/renderer/atoms/userSettingsAtom.ts
@@ -5,12 +5,16 @@ export const customModelsPathAtom = atomWithStorage<string | null>(
"customModelsPath",
null,
);
+
export const scaleAtom = atomWithStorage<"2" | "3" | "4">("scale", "4");
+
export const batchModeAtom = atom<boolean>(false);
-export const outputPathAtom = atomWithStorage<string | null>(
- "lastOutputFolderPath",
+
+export const savedOutputPathAtom = atomWithStorage<string | null>(
+ "savedOutputPath",
null,
);
+
export const progressAtom = atom<string>("");
export const rememberOutputFolderAtom = atomWithStorage<boolean>(
diff --git a/renderer/components/settings-tab/SaveOutputFolderToggle.tsx b/renderer/components/settings-tab/SaveOutputFolderToggle.tsx
index dd4b062..33e714e 100644
--- a/renderer/components/settings-tab/SaveOutputFolderToggle.tsx
+++ b/renderer/components/settings-tab/SaveOutputFolderToggle.tsx
@@ -1,11 +1,11 @@
import {
- outputPathAtom,
+ savedOutputPathAtom,
rememberOutputFolderAtom,
} from "@/atoms/userSettingsAtom";
import { useAtom } from "jotai";
export function SaveOutputFolderToggle() {
- const [outputPath, setOutputPath] = useAtom(outputPathAtom);
+ const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom);
const [rememberOutputFolder, setRememberOutputFolder] = useAtom(
rememberOutputFolderAtom,
);
diff --git a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx
index 5c3a287..4f34d94 100644
--- a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx
+++ b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx
@@ -7,7 +7,7 @@ import { modelsListAtom } from "../../../atoms/modelsListAtom";
import useLog from "../../hooks/useLog";
import {
noImageProcessingAtom,
- outputPathAtom,
+ savedOutputPathAtom,
progressAtom,
rememberOutputFolderAtom,
scaleAtom,
@@ -63,7 +63,7 @@ function LeftPaneImageSteps({
const modelOptions = useAtomValue(modelsListAtom);
const scale = useAtomValue(scaleAtom);
const noImageProcessing = useAtomValue(noImageProcessingAtom);
- const [outputPath, setOutputPath] = useAtom(outputPathAtom);
+ const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom);
const [progress, setProgress] = useAtom(progressAtom);
const rememberOutputFolder = useAtomValue(rememberOutputFolderAtom);
diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx
index bda5ccd..4155fe0 100644
--- a/renderer/pages/index.tsx
+++ b/renderer/pages/index.tsx
@@ -19,7 +19,7 @@ import {
compressionAtom,
dontShowCloudModalAtom,
noImageProcessingAtom,
- outputPathAtom,
+ savedOutputPathAtom,
overwriteAtom,
progressAtom,
scaleAtom,
@@ -67,7 +67,7 @@ const Home = () => {
const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 });
// ATOMIC STATES
- const [outputPath, setOutputPath] = useAtom(outputPathAtom);
+ const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom);
const [compression, setCompression] = useAtom(compressionAtom);
const [progress, setProgress] = useAtom(progressAtom);
const [batchMode, setBatchMode] = useAtom(batchModeAtom);