1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-02-20 20:51:49 +01:00

Fix options

This commit is contained in:
Nayam Amarshe 2023-09-17 17:07:57 +05:30
parent 4d996dc380
commit 8d34704d38
2 changed files with 19 additions and 10 deletions

View File

@ -2,6 +2,7 @@ import fs from "fs";
import { modelsPath } from "../utils/get-resource-paths";
import COMMAND from "../constants/commands";
import {
compression,
customModelsFolderPath,
folderPath,
outputFolderPath,
@ -133,14 +134,16 @@ const imageUpscayl = async (event, payload) => {
// Free up memory
upscayl.kill();
try {
await convertAndScale(
inputDir + slash + fullfileName,
isAlpha ? outFile + ".png" : outFile,
outFile,
payload.scale,
saveImageAs,
onError
);
if (saveImageAs !== "png" && scale !== "4" && compression !== 0) {
await convertAndScale(
inputDir + slash + fullfileName,
isAlpha ? outFile + ".png" : outFile,
outFile,
payload.scale,
saveImageAs,
onError
);
}
mainWindow.setProgressBar(-1);
mainWindow.webContents.send(
COMMAND.UPSCAYL_DONE,

View File

@ -36,8 +36,14 @@ const convertAndScale = async (
limitInputPixels: false,
})
.toFormat(saveImageAs as keyof FormatEnum, {
quality: 100 - (compression === 100 ? 99 : compression),
compressionLevel,
...(saveImageAs === "jpg" && {
quality: 100 - (compression === 100 ? 99 : compression),
chromaSubsampling: "4:4:4",
}),
...(saveImageAs === "png" && {
compressionLevel,
}),
force: true,
})
.withMetadata({
orientation: originalImage.orientation,