1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-19 01:24:09 +01:00

Fix noImageProcessing

This commit is contained in:
Nayam Amarshe 2023-09-19 20:34:31 +05:30
parent de2c7c501b
commit 6b6d42fadc
3 changed files with 68 additions and 40 deletions

View File

@ -3,6 +3,7 @@ import { getMainWindow } from "../main-window";
import { import {
childProcesses, childProcesses,
customModelsFolderPath, customModelsFolderPath,
noImageProcessing,
outputFolderPath, outputFolderPath,
saveOutputFolder, saveOutputFolder,
setStopped, setStopped,
@ -115,6 +116,12 @@ const batchUpscayl = async (event, payload) => {
logit("♻ Scaling and converting now..."); logit("♻ Scaling and converting now...");
upscayl.kill(); upscayl.kill();
mainWindow && mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); 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 folder // Get number of files in output folder
const files = fs.readdirSync(inputDir); const files = fs.readdirSync(inputDir);
try { try {

View File

@ -3,6 +3,7 @@ import { getMainWindow } from "../main-window";
import { import {
childProcesses, childProcesses,
customModelsFolderPath, customModelsFolderPath,
noImageProcessing,
outputFolderPath, outputFolderPath,
saveOutputFolder, saveOutputFolder,
setStopped, setStopped,
@ -42,21 +43,24 @@ const doubleUpscayl = async (event, payload) => {
const fullfileName = imagePath.split(slash).slice(-1)[0] as string; const fullfileName = imagePath.split(slash).slice(-1)[0] as string;
const fileName = parse(fullfileName).name; const fileName = parse(fullfileName).name;
let scale = "4"; let initialScale = "4";
if (model.includes("x2")) { if (model.includes("x2")) {
scale = "2"; initialScale = "2";
} else if (model.includes("x3")) { } else if (model.includes("x3")) {
scale = "3"; initialScale = "3";
} else { } else {
scale = "4"; initialScale = "4";
} }
const desiredScale = parseInt(payload.scale) * parseInt(payload.scale);
const outFile = const outFile =
outputDir + outputDir +
slash + slash +
fileName + fileName +
"_upscayl_" + "_upscayl_" +
parseInt(payload.scale) * parseInt(payload.scale) + (noImageProcessing
? parseInt(initialScale) * parseInt(initialScale)
: desiredScale) +
"x_" + "x_" +
model + model +
"." + "." +
@ -73,7 +77,7 @@ const doubleUpscayl = async (event, payload) => {
model, model,
gpuId, gpuId,
saveImageAs, saveImageAs,
scale initialScale
), ),
logit logit
); );
@ -124,6 +128,24 @@ const doubleUpscayl = async (event, payload) => {
logit("💯 Done upscaling"); logit("💯 Done upscaling");
logit("♻ Scaling and converting now..."); logit("♻ Scaling and converting now...");
mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); 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 { try {
await convertAndScale( await convertAndScale(
inputDir + slash + fullfileName, inputDir + slash + fullfileName,
@ -173,7 +195,7 @@ const doubleUpscayl = async (event, payload) => {
model, model,
gpuId, gpuId,
saveImageAs, saveImageAs,
scale initialScale
), ),
logit logit
); );

View File

@ -146,7 +146,17 @@ const imageUpscayl = async (event, payload) => {
if (!failed && !stopped) { if (!failed && !stopped) {
logit("💯 Done upscaling"); logit("💯 Done upscaling");
logit("♻ Scaling and converting now..."); logit("♻ Scaling and converting now...");
if (noImageProcessing === false) { if (noImageProcessing) {
logit("🚫 Skipping scaling and converting");
mainWindow.setProgressBar(-1);
mainWindow.webContents.send(
COMMAND.UPSCAYL_DONE,
outFile.replace(
/([^/\\]+)$/i,
encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])
)
);
}
mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING); mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING);
// Free up memory // Free up memory
upscayl.kill(); upscayl.kill();
@ -178,17 +188,6 @@ const imageUpscayl = async (event, payload) => {
"Error processing (scaling and converting) the image. Please report this error on Upscayl GitHub Issues page." "Error processing (scaling and converting) the image. Please report this error on Upscayl GitHub Issues page."
); );
} }
} else {
logit("🚫 Skipping scaling and converting");
mainWindow.setProgressBar(-1);
mainWindow.webContents.send(
COMMAND.UPSCAYL_DONE,
outFile.replace(
/([^/\\]+)$/i,
encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])
)
);
}
} }
}; };