mirror of
https://github.com/upscayl/upscayl.git
synced 2024-09-24 03:18:28 +02:00
Fix #646
This commit is contained in:
parent
701b11875a
commit
54fc57f633
@ -145,20 +145,37 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
files.forEach(async (file) => {
|
||||
if (file.startsWith(".") || file === outputFolderName) return;
|
||||
console.log("Filename: ", removeFileExtension(file));
|
||||
let upscaledImagePath = `${outputFolderPath}${slash}${removeFileExtension(
|
||||
file,
|
||||
)}.${saveImageAs}`;
|
||||
if (
|
||||
isAlpha &&
|
||||
saveImageAs === "jpg" &&
|
||||
fs.existsSync(
|
||||
`${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`,
|
||||
)
|
||||
) {
|
||||
console.log("This is an Alpha image!");
|
||||
upscaledImagePath = `${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`;
|
||||
}
|
||||
await convertAndScale(
|
||||
inputDir + slash + file,
|
||||
isAlpha
|
||||
? `${outputFolderPath}${slash}${removeFileExtension(file)}.png`
|
||||
: `${outputFolderPath}${slash}${removeFileExtension(
|
||||
file,
|
||||
)}.${saveImageAs}`,
|
||||
upscaledImagePath,
|
||||
`${outputFolderPath}${slash}${removeFileExtension(
|
||||
file,
|
||||
)}.${saveImageAs}`,
|
||||
desiredScale,
|
||||
saveImageAs,
|
||||
isAlpha,
|
||||
);
|
||||
if (
|
||||
isAlpha &&
|
||||
saveImageAs === "jpg" &&
|
||||
fs.existsSync(
|
||||
`${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`,
|
||||
)
|
||||
) {
|
||||
fs.unlinkSync(upscaledImagePath);
|
||||
}
|
||||
});
|
||||
mainWindow.webContents.send(
|
||||
COMMAND.FOLDER_UPSCAYL_DONE,
|
||||
|
@ -161,7 +161,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
||||
outFile,
|
||||
desiredScale.toString(),
|
||||
saveImageAs,
|
||||
isAlpha,
|
||||
);
|
||||
mainWindow.setProgressBar(-1);
|
||||
mainWindow.webContents.send(
|
||||
|
@ -176,7 +176,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
||||
outFile,
|
||||
desiredScale,
|
||||
saveImageAs,
|
||||
isAlpha,
|
||||
);
|
||||
// Remove the png file (default) if the saveImageAs is not png
|
||||
// fs.access(
|
||||
|
@ -10,9 +10,8 @@ const convertAndScale = async (
|
||||
processedImagePath: string,
|
||||
scale: string,
|
||||
saveImageAs: ImageFormat,
|
||||
isAlpha: boolean,
|
||||
) => {
|
||||
if (!isAlpha && !customWidth && scale === "4" && compression === 0) {
|
||||
if (!customWidth && scale === "4" && compression === 0) {
|
||||
logit("Skipping compression for 4x scale and 0% compression");
|
||||
return;
|
||||
}
|
||||
@ -36,7 +35,6 @@ const convertAndScale = async (
|
||||
if (!originalImage) {
|
||||
throw new Error("Could not grab the original image!");
|
||||
}
|
||||
console.log("🚀 => originalImage:", originalImage);
|
||||
|
||||
// Convert compression percentage (0-100) to compressionLevel (0-9)
|
||||
const compressionLevel = Math.round((compression / 100) * 9);
|
||||
@ -71,8 +69,6 @@ const convertAndScale = async (
|
||||
orientation: originalImage.orientation,
|
||||
});
|
||||
|
||||
console.log("🚀 => newImage:", newImage);
|
||||
|
||||
const buffer = await newImage
|
||||
.withMetadata({
|
||||
density: originalImage.density,
|
||||
|
@ -6,6 +6,9 @@ const logit = (...args: any) => {
|
||||
const mainWindow = getMainWindow();
|
||||
if (!mainWindow) return;
|
||||
log.log(...args);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
return;
|
||||
}
|
||||
mainWindow.webContents.send(COMMAND.LOG, args.join(" "));
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user