mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-25 22:47:59 +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 mainWindow = getMainWindow();
|
||||||
|
|
||||||
const originalImage = await sharp(originalImagePath).metadata();
|
const originalImage = await sharp(originalImagePath).metadata();
|
||||||
|
|
||||||
if (!mainWindow || !originalImage) {
|
if (!mainWindow || !originalImage) {
|
||||||
throw new Error("Could not grab the original image!");
|
throw new Error("Could not grab the original image!");
|
||||||
}
|
}
|
||||||
// Resize the image to the scale
|
// Resize the image to the scale
|
||||||
const newImage = sharp(upscaledImagePath, {
|
const newImage = sharp(upscaledImagePath, {
|
||||||
limitInputPixels: false,
|
limitInputPixels: false,
|
||||||
})
|
}).resize(
|
||||||
.resize(
|
originalImage.width && originalImage.width * parseInt(scale),
|
||||||
originalImage.width && originalImage.width * parseInt(scale),
|
originalImage.height && originalImage.height * parseInt(scale)
|
||||||
originalImage.height && originalImage.height * parseInt(scale)
|
);
|
||||||
)
|
|
||||||
.withMetadata(); // Keep metadata
|
|
||||||
|
|
||||||
// Convert compression percentage (0-100) to compressionLevel (0-9)
|
// Convert compression percentage (0-100) to compressionLevel (0-9)
|
||||||
const compressionLevel = Math.round((compression / 100) * 9);
|
const compressionLevel = Math.round((compression / 100) * 9);
|
||||||
@ -36,14 +35,20 @@ const convertAndScale = async (
|
|||||||
console.log("compression: ", compression);
|
console.log("compression: ", compression);
|
||||||
newImage.jpeg({
|
newImage.jpeg({
|
||||||
quality: 100 - (compression === 100 ? 99 : compression),
|
quality: 100 - (compression === 100 ? 99 : compression),
|
||||||
|
chromaSubsampling: "4:4:4",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Save the image
|
|
||||||
const buffer = await newImage.toBuffer();
|
const buffer = await newImage.toBuffer();
|
||||||
try {
|
try {
|
||||||
await sharp(buffer, {
|
await sharp(buffer, {
|
||||||
limitInputPixels: false,
|
limitInputPixels: false,
|
||||||
}).toFile(processedImagePath);
|
})
|
||||||
|
.withMetadata({
|
||||||
|
orientation: originalImage.orientation,
|
||||||
|
density: originalImage.density,
|
||||||
|
})
|
||||||
|
.toFile(processedImagePath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logit("❌ Error converting to: ", saveImageAs, error);
|
logit("❌ Error converting to: ", saveImageAs, error);
|
||||||
onError(error);
|
onError(error);
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "upscayl",
|
"name": "upscayl",
|
||||||
"version": "2.8.5",
|
"version": "2.8.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user