π Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.
TypeScript aielectronesrgangigapixelgigapixel-imagesimageimage-upscalingtopazupscaleupscalerimageupscayl
Add support for alpha channel in batch upscayl
Nayam Amarshef7803f7c9e44
diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.tsindex 67c32de..e1de7e0 100644--- a/electron/commands/batch-upscayl.ts+++ b/electron/commands/batch-upscayl.ts@@ -84,6 +84,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {setStopped(false);let failed = false;+ let isAlpha = false;const onData = (data: any) => {if (!mainWindow) return;@@ -97,6 +98,9 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {failed = true;upscayl.kill();}+ if (data.includes("has alpha channel")) {+ isAlpha = true;+ }};const onError = (data: any) => {if (!mainWindow) return;@@ -138,9 +142,11 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {console.log("Filename: ", removeFileExtension(file));await convertAndScale(inputDir + slash + file,- `${outputFolderPath}${slash}${removeFileExtension(- file- )}.${saveImageAs}`,+ isAlpha+ ? `${outputFolderPath}${slash}${removeFileExtension(file)}.png`+ : `${outputFolderPath}${slash}${removeFileExtension(+ file+ )}.${saveImageAs}`,`${outputFolderPath}${slash}${removeFileExtension(file)}.${saveImageAs}`,diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.tsindex ba740da..cde4235 100644--- a/electron/commands/double-upscayl.ts+++ b/electron/commands/double-upscayl.ts@@ -26,6 +26,7 @@ import { DoubleUpscaylPayload } from "../../common/types/types";import { ImageFormat } from "../utils/types";import getModelScale from "../../common/check-model-scale";import showNotification from "../utils/show-notification";+import { unlinkSync } from "fs";const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {const mainWindow = getMainWindow();@@ -162,16 +163,14 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {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])- )+ outFile.replace(+ /([^/\\]+)$/i,+ encodeURIComponent(outFile.match(/[^/\\]+$/i)![0])+ ));+ if (isAlpha && saveImageAs === "jpg") {+ unlinkSync(outFile + ".png");+ }showNotification("Upscayled", "Image upscayled successfully!");} catch (error) {logit("β Error reading original image metadata", error);