diff --git a/common/feature-flags.ts b/common/feature-flags.ts index 7436ffb..39e5241 100644 --- a/common/feature-flags.ts +++ b/common/feature-flags.ts @@ -4,6 +4,6 @@ type FeatureFlags = { }; export const featureFlags: FeatureFlags = { - APP_STORE_BUILD: true, + APP_STORE_BUILD: false, SHOW_UPSCAYL_CLOUD_INFO: false, }; diff --git a/common/types/types.d.ts b/common/types/types.d.ts index f2b2788..79c18a1 100644 --- a/common/types/types.d.ts +++ b/common/types/types.d.ts @@ -6,7 +6,7 @@ export type ImageUpscaylPayload = { gpuId: string; saveImageAs: string; overwrite: boolean; - compression: number; + compression: string; noImageProcessing: boolean; }; @@ -17,7 +17,7 @@ export type DoubleUpscaylPayload = { scale: string; gpuId: string; saveImageAs: string; - compression: number; + compression: string; noImageProcessing: boolean; }; @@ -28,6 +28,6 @@ export type BatchUpscaylPayload = { gpuId: string; saveImageAs: string; scale: string; - compression: number; + compression: string; noImageProcessing: boolean; }; diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.ts index d7d0972..a964c36 100644 --- a/electron/commands/batch-upscayl.ts +++ b/electron/commands/batch-upscayl.ts @@ -6,6 +6,7 @@ import { noImageProcessing, outputFolderPath, saveOutputFolder, + setCompression, setNoImageProcessing, setStopped, stopped, @@ -39,6 +40,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { } setNoImageProcessing(payload.noImageProcessing); + setCompression(parseInt(payload.compression)); const isDefaultModel = DEFAULT_MODELS.includes(model); diff --git a/electron/commands/custom-models-select.ts b/electron/commands/custom-models-select.ts index 01ed980..09b942d 100644 --- a/electron/commands/custom-models-select.ts +++ b/electron/commands/custom-models-select.ts @@ -9,6 +9,7 @@ import COMMAND from "../constants/commands"; import getModels from "../utils/get-models"; import { getMainWindow } from "../main-window"; import settings from "electron-settings"; +import { featureFlags } from "../../common/feature-flags"; const customModelsSelect = async (event, message) => { const mainWindow = getMainWindow(); @@ -26,7 +27,7 @@ const customModelsSelect = async (event, message) => { message: "Select Custom Models Folder that is named 'models'", }); - if (bookmarks && bookmarks.length > 0) { + if (featureFlags.APP_STORE_BUILD && bookmarks && bookmarks.length > 0) { console.log("🚨 Setting Bookmark: ", bookmarks); await settings.set("custom-models-bookmarks", bookmarks[0]); } diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.ts index 794a8ff..476b744 100644 --- a/electron/commands/double-upscayl.ts +++ b/electron/commands/double-upscayl.ts @@ -6,6 +6,7 @@ import { noImageProcessing, outputFolderPath, saveOutputFolder, + setCompression, setNoImageProcessing, setStopped, stopped, @@ -39,6 +40,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { const saveImageAs = payload.saveImageAs as string; setNoImageProcessing(payload.noImageProcessing); + setCompression(parseInt(payload.compression)); const isDefaultModel = DEFAULT_MODELS.includes(model); diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.ts index eba36d6..dbcbf4a 100644 --- a/electron/commands/image-upscayl.ts +++ b/electron/commands/image-upscayl.ts @@ -10,6 +10,7 @@ import { overwrite, saveOutputFolder, setChildProcesses, + setCompression, setNoImageProcessing, setOverwrite, setStopped, @@ -35,6 +36,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { setOverwrite(payload.overwrite); setNoImageProcessing(payload.noImageProcessing); + setCompression(parseInt(payload.compression)); const model = payload.model as string; const gpuId = payload.gpuId as string; diff --git a/electron/commands/select-file.ts b/electron/commands/select-file.ts index 71caff1..ec9b813 100644 --- a/electron/commands/select-file.ts +++ b/electron/commands/select-file.ts @@ -3,6 +3,7 @@ import { getMainWindow } from "../main-window"; import { imagePath, setImagePath } from "../utils/config-variables"; import logit from "../utils/logit"; import settings from "electron-settings"; +import { featureFlags } from "../../common/feature-flags"; const selectFile = async () => { const mainWindow = getMainWindow(); @@ -30,7 +31,7 @@ const selectFile = async () => { ], }); - if (bookmarks && bookmarks.length > 0) { + if (featureFlags.APP_STORE_BUILD && bookmarks && bookmarks.length > 0) { console.log("🚨 Setting Bookmark: ", bookmarks); settings.set("file-bookmarks", bookmarks[0]); } diff --git a/electron/commands/select-folder.ts b/electron/commands/select-folder.ts index 2796820..ded1f04 100644 --- a/electron/commands/select-folder.ts +++ b/electron/commands/select-folder.ts @@ -2,11 +2,12 @@ import { app, dialog } from "electron"; import { folderPath, setFolderPath } from "../utils/config-variables"; import logit from "../utils/logit"; import settings from "electron-settings"; +import { featureFlags } from "../../common/feature-flags"; const selectFolder = async (event, message) => { let closeAccess; const folderBookmarks = await settings.get("folder-bookmarks"); - if (folderBookmarks) { + if (featureFlags.APP_STORE_BUILD && folderBookmarks) { logit("🚨 Folder Bookmarks: ", folderBookmarks); try { closeAccess = app.startAccessingSecurityScopedResource( @@ -27,7 +28,7 @@ const selectFolder = async (event, message) => { securityScopedBookmarks: true, }); - if (bookmarks && bookmarks.length > 0) { + if (featureFlags.APP_STORE_BUILD && bookmarks && bookmarks.length > 0) { console.log("🚨 Setting folder Bookmark: ", bookmarks); await settings.set("folder-bookmarks", bookmarks[0]); } diff --git a/electron/index.ts b/electron/index.ts index e9d170e..4cce432 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -47,7 +47,7 @@ app.on("ready", async () => { let closeAccess; const folderBookmarks = await settings.get("folder-bookmarks"); - if (folderBookmarks) { + if (featureFlags.APP_STORE_BUILD && folderBookmarks) { logit("🚨 Folder Bookmarks: ", folderBookmarks); try { closeAccess = app.startAccessingSecurityScopedResource( diff --git a/electron/utils/convert-and-scale.ts b/electron/utils/convert-and-scale.ts index f2fcbdb..cf38044 100644 --- a/electron/utils/convert-and-scale.ts +++ b/electron/utils/convert-and-scale.ts @@ -66,9 +66,16 @@ const convertAndScale = async ( quality: 100 - (compression === 100 ? 99 : compression), chromaSubsampling: "4:4:4", }), - ...(saveImageAs === "png" && { - compressionLevel, - }), + // For PNGs, compression enables indexed colors automatically, + // so we need to warn the user that this will happen + // https://sharp.pixelplumbing.com/api-output#png + ...(saveImageAs === "png" && + compression > 0 && { + ...(compression > 0 && { + quality: 100 - (compression === 100 ? 99 : compression), + }), + compressionLevel: 9, + }), force: true, }) .withMetadata({ diff --git a/electron/utils/get-models.ts b/electron/utils/get-models.ts index 69f017e..4905b79 100644 --- a/electron/utils/get-models.ts +++ b/electron/utils/get-models.ts @@ -2,6 +2,7 @@ import fs from "fs"; import logit from "./logit"; import { MessageBoxOptions, app, dialog } from "electron"; import settings from "electron-settings"; +import { featureFlags } from "../../common/feature-flags"; const getModels = async (folderPath: string | undefined) => { let models: string[] = []; @@ -10,7 +11,7 @@ const getModels = async (folderPath: string | undefined) => { // SECURITY SCOPED BOOKMARKS let closeAccess; const customModelsBookmarks = await settings.get("custom-models-bookmarks"); - if (customModelsBookmarks) { + if (featureFlags.APP_STORE_BUILD && customModelsBookmarks) { console.log( "🚀 => file: get-models.ts:18 => customModelsBookmarks:", customModelsBookmarks diff --git a/renderer/components/settings-tab/CompressionInput.tsx b/renderer/components/settings-tab/CompressionInput.tsx index 3180ebb..536cd91 100644 --- a/renderer/components/settings-tab/CompressionInput.tsx +++ b/renderer/components/settings-tab/CompressionInput.tsx @@ -15,6 +15,13 @@ export function CompressionInput({ EXPERIMENTAL

+ {compression > 0 && ( +

+ This option can cause color issues with some images. For PNGs, if you + use compression, they'll use indexed colors. Keep compression to 0 for + PNGs for lossless quality. +

+ )} { + if (noImageProcessing) { + setExportType("png"); + } + }, [noImageProcessing]); + return (

SAVE IMAGE AS

-

+ {/*

EXPERIMENTAL -

+

*/}
- {batchMode && ( -

- Only PNG is supported in Batch Upscayl. + {batchMode &&

} + {noImageProcessing && ( +

+ {batchMode && "Only PNG is supported in Batch Upscayl."} Only PNGs + are saved without image processing to preserve image quality.

)}
{/* PNG */} {/* JPG */} {/* WEBP diff --git a/renderer/components/settings-tab/ImageScaleSelect.tsx b/renderer/components/settings-tab/ImageScaleSelect.tsx index fee1316..332d89f 100644 --- a/renderer/components/settings-tab/ImageScaleSelect.tsx +++ b/renderer/components/settings-tab/ImageScaleSelect.tsx @@ -10,10 +10,10 @@ export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) {

IMAGE SCALE

- + {/*

EXPERIMENTAL -

+

*/}
{ saveImageAs, scale, noImageProcessing, - compression, + compression: compression.toString(), }); logit("🏁 DOUBLE_UPSCAYL"); } else if (batchMode) { @@ -463,7 +463,7 @@ const Home = () => { saveImageAs, scale, noImageProcessing, - compression, + compression: compression.toString(), }); logit("🏁 FOLDER_UPSCAYL"); } else { @@ -477,7 +477,7 @@ const Home = () => { scale, overwrite, noImageProcessing, - compression, + compression: compression.toString(), }); logit("🏁 UPSCAYL"); }