π Upscayl - #1 Free and Open Source AI Image Upscaler for Linux, MacOS and Windows.
TypeScript aielectronesrgangigapixelgigapixel-imagesimageimage-upscalingtopazupscaleupscalerimageupscayl
Fix compression
Nayam Amarshe4d996dc380ef
diff --git a/electron/utils/convert-and-scale.ts b/electron/utils/convert-and-scale.tsindex 4c10a66..333018e 100644--- a/electron/utils/convert-and-scale.ts+++ b/electron/utils/convert-and-scale.ts@@ -1,4 +1,4 @@-import sharp from "sharp";+import sharp, { FormatEnum } from "sharp";import logit from "./logit";import { getMainWindow } from "../main-window";import { compression } from "./config-variables";@@ -28,22 +28,17 @@ const convertAndScale = async (// Convert compression percentage (0-100) to compressionLevel (0-9)const compressionLevel = Math.round((compression / 100) * 9);- if (saveImageAs === "png") {- // Change the output according to the saveImageAs- newImage.png({ compressionLevel });- } else if (saveImageAs === "jpg") {- console.log("compression: ", compression);- newImage.jpeg({- quality: 100 - (compression === 100 ? 99 : compression),- chromaSubsampling: "4:4:4",- });- }+ logit("Compression: ", compression);const buffer = await newImage.toBuffer();try {await sharp(buffer, {limitInputPixels: false,})+ .toFormat(saveImageAs as keyof FormatEnum, {+ quality: 100 - (compression === 100 ? 99 : compression),+ compressionLevel,+ }).withMetadata({orientation: originalImage.orientation,density: originalImage.density,diff --git a/renderer/components/settings-tab/CompressionInput.tsx b/renderer/components/settings-tab/CompressionInput.tsxindex 3180ebb..73bb727 100644--- a/renderer/components/settings-tab/CompressionInput.tsx+++ b/renderer/components/settings-tab/CompressionInput.tsx@@ -15,6 +15,9 @@ export function CompressionInput({EXPERIMENTAL</p></div>+ <p className="text-xs text-base-content/80">+ Please restart the app after changing this setting.+ </p><inputtype="range"placeholder="Type here"