mirror of
https://github.com/upscayl/upscayl.git
synced 2025-01-19 01:24:09 +01:00
Fix noImageProcessing
This commit is contained in:
parent
de2c7c501b
commit
6b6d42fadc
@ -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 {
|
||||||
|
@ -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
|
||||||
);
|
);
|
||||||
|
@ -146,39 +146,7 @@ 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) {
|
||||||
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 {
|
|
||||||
logit("🚫 Skipping scaling and converting");
|
logit("🚫 Skipping scaling and converting");
|
||||||
mainWindow.setProgressBar(-1);
|
mainWindow.setProgressBar(-1);
|
||||||
mainWindow.webContents.send(
|
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."
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user