π Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.
TypeScript aielectronesrgangigapixelgigapixel-imagesimageimage-upscalingtopazupscaleupscalerimageupscayl
Fix noImageProcessing
Nayam Amarshe6b6d42fadc0b
diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.tsindex 436ba62..04ee8da 100644--- a/electron/commands/batch-upscayl.ts+++ b/electron/commands/batch-upscayl.ts@@ -3,6 +3,7 @@ import { getMainWindow } from "../main-window";import {childProcesses,customModelsFolderPath,+ noImageProcessing,outputFolderPath,saveOutputFolder,setStopped,@@ -115,6 +116,12 @@ const batchUpscayl = async (event, payload) => {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, outputDir);+ return;+ }// Get number of files in output folderconst files = fs.readdirSync(inputDir);try {diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.tsindex b91f7f3..7543acb 100644--- a/electron/commands/double-upscayl.ts+++ b/electron/commands/double-upscayl.ts@@ -3,6 +3,7 @@ import { getMainWindow } from "../main-window";import {childProcesses,customModelsFolderPath,+ noImageProcessing,outputFolderPath,saveOutputFolder,setStopped,@@ -42,21 +43,24 @@ const doubleUpscayl = async (event, payload) => {const fullfileName = imagePath.split(slash).slice(-1)[0] as string;const fileName = parse(fullfileName).name;- let scale = "4";+ let initialScale = "4";if (model.includes("x2")) {- scale = "2";+ initialScale = "2";} else if (model.includes("x3")) {- scale = "3";+ initialScale = "3";} else {- scale = "4";+ initialScale = "4";}+ const desiredScale = parseInt(payload.scale) * parseInt(payload.scale);const outFile =outputDir +slash +fileName +"_upscayl_" +- parseInt(payload.scale) * parseInt(payload.scale) ++ (noImageProcessing+ ? parseInt(initialScale) * parseInt(initialScale)+ : desiredScale) +"x_" +model +"." +@@ -73,7 +77,7 @@ const doubleUpscayl = async (event, payload) => {model,gpuId,saveImageAs,- scale+ initialScale),logit);@@ -124,6 +128,24 @@ const doubleUpscayl = async (event, payload) => {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,+ isAlpha+ ? (outFile + ".png").replace(+ /([^/\\]+)$/i,+ encodeURIComponent((outFile + ".png").match(/[^/\\]+$/i)![0])+ )+ : outFile.replace(+ /([^/\\]+)$/i,+ encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])+ )+ );+ return;+ }+try {await convertAndScale(inputDir + slash + fullfileName,@@ -173,7 +195,7 @@ const doubleUpscayl = async (event, payload) => {model,gpuId,saveImageAs,- scale+ initialScale),logit);diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.tsindex 12ba4c3..f683749 100644--- a/electron/commands/image-upscayl.ts+++ b/electron/commands/image-upscayl.ts@@ -146,39 +146,7 @@ const imageUpscayl = async (event, payload) => {if (!failed && !stopped) {logit("π― Done upscaling");logit("β» Scaling and converting now...");- if (noImageProcessing === false) {- mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING);- // Free up memory- upscayl.kill();- try {- await convertAndScale(- inputDir + slash + fullfileName,- isAlpha ? outFile + ".png" : outFile,- outFile,- desiredScale,- saveImageAs,- onError- );- mainWindow.setProgressBar(-1);- mainWindow.webContents.send(- COMMAND.UPSCAYL_DONE,- outFile.replace(- /([^/\\]+)$/i,- encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])- )- );- } catch (error) {- logit(- "β Error processing (scaling and converting) the image. Please report this error on GitHub.",- error- );- upscayl.kill();- mainWindow.webContents.send(- COMMAND.UPSCAYL_ERROR,- "Error processing (scaling and converting) the image. Please report this error on Upscayl GitHub Issues page."- );- }- } else {+ if (noImageProcessing) {logit("π« Skipping scaling and converting");mainWindow.setProgressBar(-1);mainWindow.webContents.send(@@ -189,6 +157,37 @@ const imageUpscayl = async (event, payload) => {));}+ mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING);+ // Free up memory+ upscayl.kill();+ try {+ await convertAndScale(+ inputDir + slash + fullfileName,+ isAlpha ? outFile + ".png" : outFile,+ outFile,+ desiredScale,+ saveImageAs,+ onError+ );+ mainWindow.setProgressBar(-1);+ mainWindow.webContents.send(+ COMMAND.UPSCAYL_DONE,+ outFile.replace(+ /([^/\\]+)$/i,+ encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])+ )+ );+ } catch (error) {+ logit(+ "β Error processing (scaling and converting) the image. Please report this error on GitHub.",+ error+ );+ upscayl.kill();+ mainWindow.webContents.send(+ COMMAND.UPSCAYL_ERROR,+ "Error processing (scaling and converting) the image. Please report this error on Upscayl GitHub Issues page."+ );+ }}};