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:
parent
9682fb41bd
commit
34db484936
@ -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(
|
||||
}).resize(
|
||||
originalImage.width && originalImage.width * parseInt(scale),
|
||||
originalImage.height && originalImage.height * parseInt(scale)
|
||||
)
|
||||
.withMetadata(); // Keep metadata
|
||||
);
|
||||
|
||||
// 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
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "upscayl",
|
||||
"version": "2.8.5",
|
||||
"version": "2.8.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
Loading…
Reference in New Issue
Block a user