Skip to content

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

Fix #787

Nayam Amarshe6f8df14ed96b
diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.ts
index 5caf5f2..c83c056 100644
--- a/electron/commands/batch-upscayl.ts
+++ b/electron/commands/batch-upscayl.ts
@@ -3,7 +3,6 @@ import { getMainWindow } from "../main-window";
import {
childProcesses,
savedCustomModelsPath,
- noImageProcessing,
rememberOutputFolder,
setCompression,
setNoImageProcessing,
@@ -17,7 +16,7 @@ import slash from "../utils/slash";
import { modelsPath } from "../utils/get-resource-paths";
import COMMAND from "../../common/commands";
import { BatchUpscaylPayload } from "../../common/types/types";
-import { ImageFormat } from "../utils/types";
+import { ImageFormat } from "../types/types";
import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.ts
index d8c5fda..db16b43 100644
--- a/electron/commands/double-upscayl.ts
+++ b/electron/commands/double-upscayl.ts
@@ -3,7 +3,6 @@ import { getMainWindow } from "../main-window";
import {
childProcesses,
savedCustomModelsPath,
- noImageProcessing,
savedOutputPath,
rememberOutputFolder,
setCompression,
@@ -21,7 +20,7 @@ import { modelsPath } from "../utils/get-resource-paths";
import logit from "../utils/logit";
import COMMAND from "../../common/commands";
import { DoubleUpscaylPayload } from "../../common/types/types";
-import { ImageFormat } from "../utils/types";
+import { ImageFormat } from "../types/types";
import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
@@ -76,8 +75,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
model,
gpuId,
saveImageAs,
- scale: scale.toString(),
- customWidth,
}),
logit,
);
diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.ts
index b0a175a..04e41f1 100644
--- a/electron/commands/image-upscayl.ts
+++ b/electron/commands/image-upscayl.ts
@@ -5,7 +5,6 @@ import {
savedCompression,
savedCustomModelsPath,
savedBatchUpscaylFolderPath,
- noImageProcessing,
savedOutputPath,
rememberOutputFolder,
setChildProcesses,
@@ -21,8 +20,7 @@ import { spawnUpscayl } from "../utils/spawn-upscayl";
import { parse } from "path";
import { getMainWindow } from "../main-window";
import { ImageUpscaylPayload } from "../../common/types/types";
-import { ImageFormat } from "../utils/types";
-import getModelScale from "../../common/check-model-scale";
+import { ImageFormat } from "../types/types";
import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
diff --git a/electron/utils/types.d.ts b/electron/types/types.d.ts
similarity index 100%
rename from electron/utils/types.d.ts
rename to electron/types/types.d.ts
diff --git a/electron/utils/get-arguments.ts b/electron/utils/get-arguments.ts
index 687c078..0ef6580 100644
--- a/electron/utils/get-arguments.ts
+++ b/electron/utils/get-arguments.ts
@@ -1,5 +1,6 @@
+import getModelScale from "@common/check-model-scale";
import { getPlatform } from "./get-device-specs";
-import { ImageFormat } from "./types";
+import { ImageFormat } from "../types/types";
const slash: string = getPlatform() === "win" ? "\\" : "/";
export const getSingleImageArguments = ({
@@ -18,25 +19,38 @@ export const getSingleImageArguments = ({
outFile: string;
modelsPath: string;
model: string;
- scale: any;
+ scale: string;
gpuId: string;
saveImageAs: ImageFormat;
customWidth: string;
}) => {
+ const modelScale = getModelScale(model);
+ let includeScale = modelScale !== scale && !customWidth;
return [
+ // INPUT IMAGE
"-i",
inputDir + slash + fullfileName,
+ // OUTPUT IMAGE
"-o",
outFile,
- customWidth ? "" : `-s ${scale}`,
+ // OUTPUT SCALE
+ includeScale ? "-s" : "",
+ includeScale ? scale : "",
+ // MODELS PATH
"-m",
modelsPath,
+ // MODEL NAME
"-n",
model,
- gpuId ? `-g ${gpuId}` : "",
+ // GPU ID
+ gpuId ? "-g" : "",
+ gpuId ? gpuId : "",
+ // FORMAT
"-f",
saveImageAs,
- customWidth ? `-w ${customWidth}` : "",
+ // CUSTOM WIDTH
+ customWidth ? `-w` : "",
+ customWidth ? customWidth : "",
];
};
@@ -48,8 +62,6 @@ export const getDoubleUpscaleArguments = ({
model,
gpuId,
saveImageAs,
- scale,
- customWidth,
}: {
inputDir: string;
fullfileName: string;
@@ -58,20 +70,24 @@ export const getDoubleUpscaleArguments = ({
model: string;
gpuId: string;
saveImageAs: ImageFormat;
- scale: string;
- customWidth: string;
}) => {
return [
+ // INPUT IMAGE
"-i",
inputDir + slash + fullfileName,
+ // OUTPUT IMAGE
"-o",
outFile,
- customWidth ? "" : `-s ${scale}`,
+ // MODELS PATH
"-m",
modelsPath,
+ // MODEL NAME
"-n",
model,
- gpuId ? `-g ${gpuId}` : "",
+ // GPU ID
+ gpuId ? `-g` : "",
+ gpuId ? gpuId : "",
+ // FORMAT
"-f",
saveImageAs,
];
@@ -94,21 +110,33 @@ export const getDoubleUpscaleSecondPassArguments = ({
scale: string;
customWidth: string;
}) => {
+ const modelScale = getModelScale(model);
+ let includeScale = modelScale !== scale && !customWidth;
return [
+ // INPUT IMAGE
"-i",
outFile,
+ // OUTPUT IMAGE
"-o",
outFile,
- "-s",
- customWidth ? "" : `-s ${scale}`,
+ // OUTPUT SCALE
+ includeScale ? "-s" : "",
+ includeScale ? scale : "",
+ // MODELS PATH
"-m",
modelsPath,
+ // MODEL NAME
"-n",
model,
- gpuId ? `-g ${gpuId}` : "",
+ // GPU ID
+ gpuId ? `-g` : "",
+ gpuId ? gpuId : "",
+ // FORMAT
"-f",
saveImageAs,
- customWidth ? `-w ${customWidth}` : "",
+ // CUSTOM WIDTH
+ customWidth ? `-w` : "",
+ customWidth ? customWidth : "",
];
};
@@ -131,19 +159,33 @@ export const getBatchArguments = ({
scale: string;
customWidth: string;
}) => {
+ const modelScale = getModelScale(model);
+ let includeScale = modelScale !== scale && !customWidth;
+
return [
+ // INPUT IMAGE
"-i",
inputDir,
+ // OUTPUT IMAGE
"-o",
outputDir,
- customWidth ? "" : `-s ${scale}`,
+ // OUTPUT SCALE
+ includeScale ? "-s" : "",
+ includeScale ? scale : "",
+ // MODELS PATH
"-m",
modelsPath,
+ // MODEL NAME
"-n",
model,
- gpuId ? `-g ${gpuId}` : "",
+ // GPU ID
+ gpuId ? `-g` : "",
+ gpuId ? gpuId : "",
+ // FORMAT
"-f",
saveImageAs,
- customWidth ? `-w ${customWidth}` : "",
+ // CUSTOM WIDTH
+ customWidth ? `-w` : "",
+ customWidth ? customWidth : "",
];
};
diff --git a/electron/utils/localstorage-variables.ts b/electron/utils/localstorage-variables.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/electron/utils/remove-file-extension.ts b/electron/utils/remove-file-extension.ts
index 9a03c12..660450d 100644
--- a/electron/utils/remove-file-extension.ts
+++ b/electron/utils/remove-file-extension.ts
@@ -1,5 +1,3 @@
-import { Dirent } from "fs";
-
/**
* Returns the filename without the extension.
* @param filename The filename to remove the extension from.