Skip to content

πŸ†™ Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.

Fix color profile

Nayam Amarshe34db484936f7
diff --git a/electron/utils/convert-and-scale.ts b/electron/utils/convert-and-scale.ts
index 15b4335..4c10a66 100644
--- a/electron/utils/convert-and-scale.ts
+++ b/electron/utils/convert-and-scale.ts
@@ -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);
diff --git a/package-lock.json b/package-lock.json
index 4898614..0704579 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "upscayl",
- "version": "2.8.5",
+ "version": "2.8.1",
"lockfileVersion": 2,
"requires": true,
"packages": {