mirror of
https://github.com/upscayl/upscayl.git
synced 2026-04-03 03:00:13 -04:00
@@ -176,6 +176,8 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
);
|
||||
|
||||
let failed = false;
|
||||
let isAlpha = false;
|
||||
|
||||
// TAKE UPSCAYL OUTPUT
|
||||
upscayl.stderr.on("data", (data) => {
|
||||
// CONVERT DATA TO STRING
|
||||
@@ -188,6 +190,9 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
if (data.includes("invalid gpu") || data.includes("failed")) {
|
||||
failed = true;
|
||||
}
|
||||
if (data.includes("has alpha channel")) {
|
||||
isAlpha = true;
|
||||
}
|
||||
});
|
||||
|
||||
// IF ERROR
|
||||
@@ -209,9 +214,9 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
execPath("realesrgan"),
|
||||
[
|
||||
"-i",
|
||||
outFile,
|
||||
isAlpha ? outFile + ".png" : outFile,
|
||||
"-o",
|
||||
outFile,
|
||||
isAlpha ? outFile + ".png" : outFile,
|
||||
"-s",
|
||||
4,
|
||||
"-m",
|
||||
@@ -220,7 +225,7 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
model,
|
||||
gpuId ? `-g ${gpuId}` : "",
|
||||
"-f",
|
||||
saveImageAs,
|
||||
isAlpha ? "" : saveImageAs,
|
||||
],
|
||||
{
|
||||
cwd: undefined,
|
||||
@@ -256,7 +261,10 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
upscayl2.on("close", (code) => {
|
||||
if (!failed2) {
|
||||
console.log("Done upscaling");
|
||||
mainWindow.webContents.send(commands.DOUBLE_UPSCAYL_DONE, outFile);
|
||||
mainWindow.webContents.send(
|
||||
commands.DOUBLE_UPSCAYL_DONE,
|
||||
isAlpha ? outFile + ".png" : outFile
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -275,14 +283,17 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
// COPY IMAGE TO TMP FOLDER
|
||||
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "");
|
||||
|
||||
console.log(fullfileName);
|
||||
const fileName = parse(fullfileName).name;
|
||||
console.log("🚀 => fileName", fileName);
|
||||
|
||||
const fileExt = parse(fullfileName).ext;
|
||||
console.log("🚀 => fileExt", fileExt);
|
||||
|
||||
const outFile = model.includes("models-DF2K")
|
||||
? outputDir +
|
||||
"/" +
|
||||
fileName +
|
||||
"_upscayl_sharpened_" +
|
||||
"_sharpened_" +
|
||||
scale +
|
||||
"x_" +
|
||||
model +
|
||||
@@ -385,8 +396,10 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
break;
|
||||
}
|
||||
|
||||
let isAlpha = false;
|
||||
let failed = false;
|
||||
upscayl?.stderr.on("data", (data) => {
|
||||
|
||||
upscayl?.stderr.on("data", (data: string) => {
|
||||
console.log(
|
||||
"🚀 => upscayl.stderr.on => stderr.toString()",
|
||||
data.toString()
|
||||
@@ -396,6 +409,10 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
if (data.includes("invalid gpu") || data.includes("failed")) {
|
||||
failed = true;
|
||||
}
|
||||
if (data.includes("has alpha channel")) {
|
||||
console.log("INCLUDES ALPHA CHANNEL, CHANGING OUTFILE NAME!");
|
||||
isAlpha = true;
|
||||
}
|
||||
});
|
||||
|
||||
upscayl?.on("error", (data) => {
|
||||
@@ -408,7 +425,10 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
upscayl?.on("close", (code) => {
|
||||
if (failed !== true) {
|
||||
console.log("Done upscaling");
|
||||
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
||||
mainWindow.webContents.send(
|
||||
commands.UPSCAYL_DONE,
|
||||
isAlpha ? outFile + ".png" : outFile
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user