1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-28 01:10:52 +01:00

Fix color profile

This commit is contained in:
Nayam Amarshe 2023-09-17 05:29:18 +05:30
parent 9682fb41bd
commit 34db484936
2 changed files with 14 additions and 9 deletions

View File

@ -14,18 +14,17 @@ const convertAndScale = async (
const mainWindow = getMainWindow();
const originalImage = await sharp(originalImagePath).metadata();
if (!mainWindow || !originalImage) {
throw new Error("Could not grab the original image!");
}
// Resize the image to the scale
const newImage = sharp(upscaledImagePath, {
limitInputPixels: false,
})
.resize(
originalImage.width && originalImage.width * parseInt(scale),
originalImage.height && originalImage.height * parseInt(scale)
)
.withMetadata(); // Keep metadata
}).resize(
originalImage.width && originalImage.width * parseInt(scale),
originalImage.height && originalImage.height * parseInt(scale)
);
// Convert compression percentage (0-100) to compressionLevel (0-9)
const compressionLevel = Math.round((compression / 100) * 9);
@ -36,14 +35,20 @@ const convertAndScale = async (
console.log("compression: ", compression);
newImage.jpeg({
quality: 100 - (compression === 100 ? 99 : compression),
chromaSubsampling: "4:4:4",
});
}
// Save the image
const buffer = await newImage.toBuffer();
try {
await sharp(buffer, {
limitInputPixels: false,
}).toFile(processedImagePath);
})
.withMetadata({
orientation: originalImage.orientation,
density: originalImage.density,
})
.toFile(processedImagePath);
} catch (error) {
logit("❌ Error converting to: ", saveImageAs, error);
onError(error);

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "upscayl",
"version": "2.8.5",
"version": "2.8.1",
"lockfileVersion": 2,
"requires": true,
"packages": {