diff --git a/electron/commands/batch-upscayl.ts b/electron/commands/batch-upscayl.ts index 64e5880..bd2864f 100644 --- a/electron/commands/batch-upscayl.ts +++ b/electron/commands/batch-upscayl.ts @@ -2,10 +2,10 @@ import fs from "fs"; import { getMainWindow } from "../main-window"; import { childProcesses, - customModelsFolderPath, + savedCustomModelsPath, customWidth, noImageProcessing, - saveOutputFolder, + rememberOutputFolder, setCompression, setNoImageProcessing, setStopped, @@ -18,7 +18,6 @@ import { getBatchArguments } from "../utils/get-arguments"; import slash from "../utils/slash"; import { modelsPath } from "../utils/get-resource-paths"; import COMMAND from "../../common/commands"; -import convertAndScale from "../utils/convert-and-scale"; import { BatchUpscaylPayload } from "../../common/types/types"; import { ImageFormat } from "../utils/types"; import getModelScale from "../../common/check-model-scale"; @@ -38,7 +37,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { let inputDir = payload.batchFolderPath; // GET THE OUTPUT DIRECTORY let outputFolderPath = payload.outputPath; - if (saveOutputFolder === true && outputFolderPath) { + if (rememberOutputFolder === true && outputFolderPath) { outputFolderPath = outputFolderPath; } // ! Don't do fetchLocalStorage() again, it causes the values to be reset @@ -47,13 +46,9 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { const isDefaultModel = DEFAULT_MODELS.includes(model); - let initialScale = getModelScale(model); + const scale = payload.scale; - const desiredScale = useCustomWidth - ? customWidth || payload.scale - : payload.scale; - - const outputFolderName = `upscayl_${saveImageAs}_${model}_${noImageProcessing ? initialScale : desiredScale}${useCustomWidth ? "px" : "x"}`; + const outputFolderName = `upscayl_${saveImageAs}_${model}_${scale}${useCustomWidth ? "px" : "x"}`; outputFolderPath += slash + outputFolderName; if (!fs.existsSync(outputFolderPath)) { fs.mkdirSync(outputFolderPath, { recursive: true }); @@ -73,15 +68,17 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { // UPSCALE const upscayl = spawnUpscayl( - getBatchArguments( + getBatchArguments({ inputDir, - outputFolderPath, - isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath, + outputDir: outputFolderPath, + modelsPath: isDefaultModel + ? modelsPath + : savedCustomModelsPath ?? modelsPath, model, gpuId, saveImageAs, - initialScale, - ), + scale, + }), logit, ); @@ -98,7 +95,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { COMMAND.FOLDER_UPSCAYL_PROGRESS, data.toString(), ); - if (data.includes("invalid") || data.includes("failed")) { + if (data.includes("Error") || data.includes("failed")) { logit("❌ INVALID GPU OR INVALID FILES IN FOLDER - FAILED"); failed = true; upscayl.kill(); @@ -139,47 +136,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { ); return; } - - const files = fs.readdirSync(inputDir); try { - files.forEach(async (file) => { - if (file.startsWith(".") || file === outputFolderName) return; - console.log("Filename: ", removeFileExtension(file)); - let upscaledImagePath = `${outputFolderPath}${slash}${removeFileExtension( - file, - )}.${saveImageAs}`; - let imageIsAlpha = false; - if ( - isAlpha && - saveImageAs === "jpg" && - fs.existsSync( - `${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`, - ) - ) { - imageIsAlpha = true; - console.log("This is an Alpha image!"); - upscaledImagePath = `${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`; - } - await convertAndScale( - inputDir + slash + file, - upscaledImagePath, - `${outputFolderPath}${slash}${removeFileExtension( - file, - )}.${saveImageAs}`, - desiredScale, - saveImageAs, - imageIsAlpha, - ); - if ( - isAlpha && - saveImageAs === "jpg" && - fs.existsSync( - `${outputFolderPath}${slash}${removeFileExtension(file)}.jpg.png`, - ) - ) { - fs.unlinkSync(upscaledImagePath); - } - }); mainWindow.webContents.send( COMMAND.FOLDER_UPSCAYL_DONE, outputFolderPath, diff --git a/electron/commands/custom-models-select.ts b/electron/commands/custom-models-select.ts index 8fe6d2e..bd2edd5 100644 --- a/electron/commands/custom-models-select.ts +++ b/electron/commands/custom-models-select.ts @@ -1,7 +1,7 @@ import { MessageBoxOptions, dialog } from "electron"; import { - customModelsFolderPath, - setCustomModelsFolderPath, + savedCustomModelsPath, + setSavedCustomModelsPath, } from "../utils/config-variables"; import logit from "../utils/logit"; import slash from "../utils/slash"; @@ -22,7 +22,7 @@ const customModelsSelect = async (event, message) => { } = await dialog.showOpenDialog({ properties: ["openDirectory"], title: "Select Custom Models Folder", - defaultPath: customModelsFolderPath, + defaultPath: savedCustomModelsPath, securityScopedBookmarks: true, message: "Select Custom Models Folder that is named 'models'", }); @@ -36,7 +36,7 @@ const customModelsSelect = async (event, message) => { logit("🚫 Select Custom Models Folder Operation Cancelled"); return null; } else { - setCustomModelsFolderPath(folderPaths[0]); + setSavedCustomModelsPath(folderPaths[0]); if ( !folderPaths[0].endsWith(slash + "models") && @@ -54,11 +54,11 @@ const customModelsSelect = async (event, message) => { return null; } - const models = await getModels(customModelsFolderPath); + const models = await getModels(savedCustomModelsPath); mainWindow.webContents.send(COMMAND.CUSTOM_MODEL_FILES_LIST, models); - logit("πŸ“ Custom Folder Path: ", customModelsFolderPath); - return customModelsFolderPath; + logit("πŸ“ Custom Folder Path: ", savedCustomModelsPath); + return savedCustomModelsPath; } }; diff --git a/electron/commands/double-upscayl.ts b/electron/commands/double-upscayl.ts index 1f9630a..e3703e7 100644 --- a/electron/commands/double-upscayl.ts +++ b/electron/commands/double-upscayl.ts @@ -2,11 +2,12 @@ import path, { parse } from "path"; import { getMainWindow } from "../main-window"; import { childProcesses, - customModelsFolderPath, + savedCustomModelsPath, customWidth, + savedBatchUpscaylFolderPath, noImageProcessing, - outputFolderPath, - saveOutputFolder, + savedOutputPath, + rememberOutputFolder, setCompression, setNoImageProcessing, setStopped, @@ -22,7 +23,6 @@ import { import { modelsPath } from "../utils/get-resource-paths"; import logit from "../utils/logit"; import COMMAND from "../../common/commands"; -import convertAndScale from "../utils/convert-and-scale"; import { DoubleUpscaylPayload } from "../../common/types/types"; import { ImageFormat } from "../utils/types"; import getModelScale from "../../common/check-model-scale"; @@ -39,8 +39,8 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { let inputDir = (imagePath.match(/(.*)[\/\\]/) || [""])[1]; let outputDir = path.normalize(payload.outputPath); - if (saveOutputFolder === true && outputFolderPath) { - outputDir = outputFolderPath; + if (rememberOutputFolder === true && savedOutputPath) { + outputDir = savedOutputPath; } const gpuId = payload.gpuId as string; const saveImageAs = payload.saveImageAs as ImageFormat; @@ -55,20 +55,14 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { const fullfileName = imagePath.split(slash).slice(-1)[0] as string; const fileName = parse(fullfileName).name; - let initialScale = getModelScale(model); - - const desiredScale = useCustomWidth - ? customWidth || parseInt(payload.scale) * parseInt(payload.scale) - : parseInt(payload.scale) * parseInt(payload.scale); + const scale = parseInt(payload.scale) * parseInt(payload.scale); const outFile = outputDir + slash + fileName + "_upscayl_" + - (noImageProcessing - ? parseInt(initialScale) * parseInt(initialScale) - : desiredScale) + + scale + (useCustomWidth ? "px_" : "x_") + model + "." + @@ -76,16 +70,18 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { // UPSCALE let upscayl = spawnUpscayl( - getDoubleUpscaleArguments( + getDoubleUpscaleArguments({ inputDir, fullfileName, outFile, - isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath, + modelsPath: isDefaultModel + ? modelsPath + : savedCustomModelsPath ?? modelsPath, model, gpuId, saveImageAs, - initialScale, - ), + scale: scale.toString(), + }), logit, ); @@ -103,11 +99,11 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { // SEND UPSCAYL PROGRESS TO RENDERER mainWindow.webContents.send(COMMAND.DOUBLE_UPSCAYL_PROGRESS, data); // IF PROGRESS HAS ERROR, UPSCAYL FAILED - if (data.includes("invalid gpu") || data.includes("failed")) { + if (data.includes("Error") || data.includes("failed")) { upscayl.kill(); failed = true; } - if (data.includes("has alpha channel")) { + if (data.includes("alpha channel")) { isAlpha = true; } }; @@ -141,28 +137,15 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { mainWindow.setProgressBar(-1); mainWindow.webContents.send( COMMAND.DOUBLE_UPSCAYL_DONE, - isAlpha - ? (outFile + ".png").replace( - /([^/\\]+)$/i, - encodeURIComponent((outFile + ".png").match(/[^/\\]+$/i)![0]), - ) - : outFile.replace( - /([^/\\]+)$/i, - encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]), - ), + outFile.replace( + /([^/\\]+)$/i, + encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]), + ), ); return; } try { - await convertAndScale( - inputDir + slash + fullfileName, - isAlpha ? outFile + ".png" : outFile, - outFile, - desiredScale.toString(), - saveImageAs, - isAlpha, - ); mainWindow.setProgressBar(-1); mainWindow.webContents.send( COMMAND.DOUBLE_UPSCAYL_DONE, @@ -171,9 +154,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { encodeURIComponent(outFile.match(/[^/\\]+$/i)![0]), ), ); - if (isAlpha && saveImageAs === "jpg") { - unlinkSync(outFile + ".png"); - } showNotification("Upscayled", "Image upscayled successfully!"); } catch (error) { logit("❌ Error reading original image metadata", error); @@ -196,15 +176,17 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { if (!failed && !stopped) { // UPSCALE let upscayl2 = spawnUpscayl( - getDoubleUpscaleSecondPassArguments( + getDoubleUpscaleSecondPassArguments({ isAlpha, outFile, - isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath, + modelsPath: isDefaultModel + ? modelsPath + : savedCustomModelsPath ?? modelsPath, model, gpuId, saveImageAs, - initialScale, - ), + scale: scale.toString(), + }), logit, ); diff --git a/electron/commands/get-models-list.ts b/electron/commands/get-models-list.ts index 7d19115..dd53bdf 100644 --- a/electron/commands/get-models-list.ts +++ b/electron/commands/get-models-list.ts @@ -1,8 +1,8 @@ import COMMAND from "../../common/commands"; import { getMainWindow } from "../main-window"; import { - customModelsFolderPath, - setCustomModelsFolderPath, + savedCustomModelsPath, + setSavedCustomModelsPath, } from "../utils/config-variables"; import getModels from "../utils/get-models"; import logit from "../utils/logit"; @@ -12,9 +12,9 @@ const getModelsList = async (event, payload) => { if (!mainWindow) return; if (payload) { - setCustomModelsFolderPath(payload); + setSavedCustomModelsPath(payload); - logit("πŸ“ Custom Models Folder Path: ", customModelsFolderPath); + logit("πŸ“ Custom Models Folder Path: ", savedCustomModelsPath); const models = await getModels(payload); mainWindow.webContents.send(COMMAND.CUSTOM_MODEL_FILES_LIST, models); diff --git a/electron/commands/image-upscayl.ts b/electron/commands/image-upscayl.ts index a18a088..54c72d2 100644 --- a/electron/commands/image-upscayl.ts +++ b/electron/commands/image-upscayl.ts @@ -2,13 +2,13 @@ import fs from "fs"; import { modelsPath } from "../utils/get-resource-paths"; import COMMAND from "../../common/commands"; import { - compression, - customModelsFolderPath, + savedCompression, + savedCustomModelsPath, customWidth, - folderPath, + savedBatchUpscaylFolderPath, noImageProcessing, - outputFolderPath, - saveOutputFolder, + savedOutputPath, + rememberOutputFolder, setChildProcesses, setCompression, setNoImageProcessing, @@ -16,7 +16,6 @@ import { stopped, useCustomWidth, } from "../utils/config-variables"; -import convertAndScale from "../utils/convert-and-scale"; import { getSingleImageArguments } from "../utils/get-arguments"; import logit from "../utils/logit"; import slash from "../utils/slash"; @@ -26,7 +25,6 @@ import { getMainWindow } from "../main-window"; import { ImageUpscaylPayload } from "../../common/types/types"; import { ImageFormat } from "../utils/types"; import getModelScale from "../../common/check-model-scale"; -import removeFileExtension from "../utils/remove-file-extension"; import showNotification from "../utils/show-notification"; import { DEFAULT_MODELS } from "../../common/models-list"; @@ -41,29 +39,27 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { setNoImageProcessing(payload.noImageProcessing); setCompression(parseInt(payload.compression)); + // GET VARIABLES const model = payload.model as string; const gpuId = payload.gpuId as string; const saveImageAs = payload.saveImageAs as ImageFormat; - console.log("πŸš€ => saveImageAs:", saveImageAs); - const overwrite = payload.overwrite as boolean; - let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)?.[1] || "") as string; let outputDir: string | undefined = - folderPath || (payload.outputPath as string); - - if (saveOutputFolder === true && outputFolderPath) { - outputDir = outputFolderPath; + savedBatchUpscaylFolderPath || (payload.outputPath as string); + if ( + rememberOutputFolder === true && + savedOutputPath && + savedOutputPath?.length > 0 + ) { + logit("🧠 Using saved output path"); + outputDir = savedOutputPath; } - const isDefaultModel = DEFAULT_MODELS.includes(model); logit("Is Default Model? : ", isDefaultModel); const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string; const fileName = parse(fullfileName).name; const fileExt = parse(fullfileName).ext; - - let initialScale = getModelScale(model); - const desiredScale = useCustomWidth ? customWidth || payload.scale : payload.scale; @@ -73,7 +69,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { slash + fileName + "_upscayl_" + - (noImageProcessing ? initialScale : desiredScale) + + desiredScale + (useCustomWidth ? "px_" : "x_") + model + "." + @@ -101,23 +97,25 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { outputDir, fullfileName, fileName, - initialScale: initialScale, + scale: desiredScale, desiredScale, outFile, - compression, + compression: savedCompression, }), ); const upscayl = spawnUpscayl( - getSingleImageArguments( + getSingleImageArguments({ inputDir, fullfileName, outFile, - isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath, + modelsPath: isDefaultModel + ? modelsPath + : savedCustomModelsPath ?? modelsPath, model, - initialScale, + scale: desiredScale, gpuId, saveImageAs, - ), + }), logit, ); @@ -170,17 +168,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { // Free up memory upscayl.kill(); try { - await convertAndScale( - inputDir + slash + fullfileName, - isAlpha ? outFile + ".png" : outFile, - outFile, - desiredScale, - saveImageAs, - isAlpha, - ); - if (isAlpha && saveImageAs === "jpg") { - fs.unlinkSync(outFile + ".png"); - } mainWindow.setProgressBar(-1); mainWindow.webContents.send( COMMAND.UPSCAYL_DONE, diff --git a/electron/commands/select-file.ts b/electron/commands/select-file.ts index ec9b813..50bd72c 100644 --- a/electron/commands/select-file.ts +++ b/electron/commands/select-file.ts @@ -1,6 +1,6 @@ import { MessageBoxOptions, app, dialog } from "electron"; import { getMainWindow } from "../main-window"; -import { imagePath, setImagePath } from "../utils/config-variables"; +import { savedImagePath, setSavedImagePath } from "../utils/config-variables"; import logit from "../utils/logit"; import settings from "electron-settings"; import { featureFlags } from "../../common/feature-flags"; @@ -11,7 +11,7 @@ const selectFile = async () => { const { canceled, filePaths, bookmarks } = await dialog.showOpenDialog({ properties: ["openFile"], title: "Select Image", - defaultPath: imagePath, + defaultPath: savedImagePath, securityScopedBookmarks: true, message: "Select Image to Upscale", filters: [ @@ -40,7 +40,7 @@ const selectFile = async () => { logit("🚫 File Operation Cancelled"); return null; } else { - setImagePath(filePaths[0]); + setSavedImagePath(filePaths[0]); let isValid = false; // READ SELECTED FILES diff --git a/electron/commands/select-folder.ts b/electron/commands/select-folder.ts index ded1f04..96bb77f 100644 --- a/electron/commands/select-folder.ts +++ b/electron/commands/select-folder.ts @@ -1,5 +1,8 @@ import { app, dialog } from "electron"; -import { folderPath, setFolderPath } from "../utils/config-variables"; +import { + savedBatchUpscaylFolderPath, + setSavedBatchUpscaylFolderPath, +} from "../utils/config-variables"; import logit from "../utils/logit"; import settings from "electron-settings"; import { featureFlags } from "../../common/feature-flags"; @@ -11,7 +14,7 @@ const selectFolder = async (event, message) => { logit("🚨 Folder Bookmarks: ", folderBookmarks); try { closeAccess = app.startAccessingSecurityScopedResource( - folderBookmarks as string + folderBookmarks as string, ); } catch (error) { logit("πŸ“ Folder Bookmarks Error: ", error); @@ -24,7 +27,7 @@ const selectFolder = async (event, message) => { bookmarks, } = await dialog.showOpenDialog({ properties: ["openDirectory"], - defaultPath: folderPath, + defaultPath: savedBatchUpscaylFolderPath, securityScopedBookmarks: true, }); @@ -37,8 +40,8 @@ const selectFolder = async (event, message) => { logit("🚫 Select Folder Operation Cancelled"); return null; } else { - setFolderPath(folderPaths[0]); - logit("πŸ“ Selected Folder Path: ", folderPath); + setSavedBatchUpscaylFolderPath(folderPaths[0]); + logit("πŸ“ Selected Folder Path: ", savedBatchUpscaylFolderPath); return folderPaths[0]; } }; diff --git a/electron/index.ts b/electron/index.ts index f15edd6..852a341 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -17,13 +17,11 @@ import { execPath, modelsPath } from "./utils/get-resource-paths"; import batchUpscayl from "./commands/batch-upscayl"; import doubleUpscayl from "./commands/double-upscayl"; import autoUpdate from "./commands/auto-update"; -import sharp from "sharp"; import { featureFlags } from "../common/feature-flags"; import settings from "electron-settings"; // INITIALIZATION log.initialize({ preload: true }); -sharp.cache(false); logit("πŸšƒ App Path: ", app.getAppPath()); app.on("ready", async () => { @@ -51,7 +49,7 @@ app.on("ready", async () => { logit("🚨 Folder Bookmarks: ", folderBookmarks); try { closeAccess = app.startAccessingSecurityScopedResource( - folderBookmarks as string + folderBookmarks as string, ); } catch (error) { logit("πŸ“ Folder Bookmarks Error: ", error); diff --git a/electron/utils/config-variables.ts b/electron/utils/config-variables.ts index 00da749..a56fb12 100644 --- a/electron/utils/config-variables.ts +++ b/electron/utils/config-variables.ts @@ -2,52 +2,81 @@ import { ChildProcessWithoutNullStreams } from "child_process"; import { getMainWindow } from "../main-window"; import logit from "./logit"; -export let imagePath: string | undefined = ""; -export let folderPath: string | undefined = undefined; -export let customModelsFolderPath: string | undefined = undefined; -export let outputFolderPath: string | undefined = undefined; -export let saveOutputFolder = false; -export let compression = 0; +/** + * The saved image path so that the select image dialog can open to the last used path. + */ +export let savedImagePath: string | undefined = ""; +export function setSavedImagePath(value: string | undefined): void { + savedImagePath = value; + logit("πŸ–ΌοΈ Updating Image Path: ", savedImagePath); +} + +/** + * The saved folder path so that the select folder to upscayl dialog can open to the last used path. + */ +export let savedBatchUpscaylFolderPath: string | undefined = undefined; +export function setSavedBatchUpscaylFolderPath( + value: string | undefined, +): void { + savedBatchUpscaylFolderPath = value; + logit("πŸ“ Updating Folder Path: ", savedBatchUpscaylFolderPath); +} + +export let savedCustomModelsPath: string | undefined = undefined; +export function setSavedCustomModelsPath(value: string | undefined): void { + savedCustomModelsPath = value; + logit("πŸ“ Updating Custom Models Folder Path: ", savedCustomModelsPath); +} + +export let savedOutputPath: string | undefined = undefined; +export function setSavedOutputPath(value: string | undefined): void { + savedOutputPath = value; + logit("πŸ“ Updating Output Folder Path: ", savedOutputPath); +} + +export let rememberOutputFolder = false; +export function setRememberOutputFolder(value: boolean): void { + rememberOutputFolder = value; + logit("πŸ’Ύ Updating Remember Output Folder: ", rememberOutputFolder); +} + +export let savedCompression = 0; +export function setCompression(value: number): void { + savedCompression = value; + logit("πŸ“ Updating Compression: ", savedCompression); +} + export let stopped = false; export let childProcesses: { process: ChildProcessWithoutNullStreams; kill: () => boolean; }[] = []; + export let noImageProcessing: boolean = false; +export function setNoImageProcessing(value: boolean): void { + noImageProcessing = value; + logit("πŸ–ΌοΈ Updating No Image Processing: ", noImageProcessing); +} + export let turnOffNotifications: boolean = false; +export function setTurnOffNotifications(value: boolean): void { + turnOffNotifications = value; + logit("πŸ”• Updating Turn Off Notifications: ", turnOffNotifications); +} + export let customWidth: string | null = null; +export function setCustomWidth(value: string | null): void { + customWidth = value; + logit("πŸ“ Updating Custom Width: ", customWidth); +} + export let useCustomWidth: boolean = false; - -export function setImagePath(value: string | undefined): void { - imagePath = value; - logit("πŸ–ΌοΈ Updating Image Path: ", imagePath); -} - -export function setFolderPath(value: string | undefined): void { - folderPath = value; - logit("πŸ“ Updating Folder Path: ", folderPath); -} - -export function setCustomModelsFolderPath(value: string | undefined): void { - customModelsFolderPath = value; - logit("πŸ“ Updating Custom Models Folder Path: ", customModelsFolderPath); +export function setUseCustomWidth(value: boolean): void { + useCustomWidth = value; + logit("πŸ“ Updating Use Custom Width: ", useCustomWidth); } // SETTERS -export function setOutputFolderPath(value: string | undefined): void { - outputFolderPath = value; - logit("πŸ“ Updating Output Folder Path: ", outputFolderPath); -} - -export function setSaveOutputFolder(value: boolean): void { - saveOutputFolder = value; - logit("πŸ’Ύ Updating Save Output Folder: ", saveOutputFolder); -} - -export function setCompression(value: number): void { - compression = value; - logit("πŸ“ Updating Compression: ", compression); -} export function setStopped(value: boolean): void { stopped = value; @@ -68,26 +97,6 @@ export function setChildProcesses(value: { ); } -export function setNoImageProcessing(value: boolean): void { - noImageProcessing = value; - logit("πŸ–ΌοΈ Updating No Image Processing: ", noImageProcessing); -} - -export function setTurnOffNotifications(value: boolean): void { - turnOffNotifications = value; - logit("πŸ”• Updating Turn Off Notifications: ", turnOffNotifications); -} - -export function setCustomWidth(value: string | null): void { - customWidth = value; - logit("πŸ“ Updating Custom Width: ", customWidth); -} - -export function setUseCustomWidth(value: boolean): void { - useCustomWidth = value; - logit("πŸ“ Updating Use Custom Width: ", useCustomWidth); -} - // LOCAL STORAGE export function fetchLocalStorage(): void { const mainWindow = getMainWindow(); @@ -98,34 +107,37 @@ export function fetchLocalStorage(): void { .executeJavaScript('localStorage.getItem("lastImagePath");', true) .then((lastImagePath: string | null) => { if (lastImagePath && lastImagePath.length > 0) { - setImagePath(lastImagePath); + setSavedImagePath(lastImagePath); } }); // GET LAST FOLDER PATH TO LOCAL STORAGE - mainWindow.webContents - .executeJavaScript('localStorage.getItem("lastFolderPath");', true) - .then((lastFolderPath: string | null) => { - if (lastFolderPath && lastFolderPath.length > 0) { - setFolderPath(lastFolderPath); - } - }); - // GET LAST CUSTOM MODELS FOLDER PATH TO LOCAL STORAGE mainWindow.webContents .executeJavaScript( - 'localStorage.getItem("lastCustomModelsFolderPath");', + 'localStorage.getItem("lastSavedBatchUpscaylFolderPath");', true, ) - .then((lastCustomModelsFolderPath: string | null) => { - if (lastCustomModelsFolderPath && lastCustomModelsFolderPath.length > 0) { - setCustomModelsFolderPath(lastCustomModelsFolderPath); + .then((lastSavedBatchUpscaylFolderPath: string | null) => { + if ( + lastSavedBatchUpscaylFolderPath && + lastSavedBatchUpscaylFolderPath.length > 0 + ) { + setSavedBatchUpscaylFolderPath(lastSavedBatchUpscaylFolderPath); } }); // GET LAST CUSTOM MODELS FOLDER PATH TO LOCAL STORAGE mainWindow.webContents - .executeJavaScript('localStorage.getItem("lastOutputFolderPath");', true) - .then((lastOutputFolderPath: string | null) => { - if (lastOutputFolderPath && lastOutputFolderPath.length > 0) { - setOutputFolderPath(lastOutputFolderPath); + .executeJavaScript('localStorage.getItem("customModelsFolderPath");', true) + .then((value: string | null) => { + if (value && value.length > 0) { + setSavedCustomModelsPath(value); + } + }); + // GET LAST CUSTOM MODELS FOLDER PATH TO LOCAL STORAGE + mainWindow.webContents + .executeJavaScript('localStorage.getItem("savedOutputPath");', true) + .then((savedOutputPath: string | null) => { + if (savedOutputPath && savedOutputPath.length > 0) { + setSavedOutputPath(savedOutputPath); } }); // GET LAST SAVE OUTPUT FOLDER (BOOLEAN) TO LOCAL STORAGE @@ -133,7 +145,7 @@ export function fetchLocalStorage(): void { .executeJavaScript('localStorage.getItem("rememberOutputFolder");', true) .then((lastSaveOutputFolder: boolean | null) => { if (lastSaveOutputFolder !== null) { - setSaveOutputFolder(lastSaveOutputFolder); + setRememberOutputFolder(lastSaveOutputFolder); } }); // GET IMAGE COMPRESSION (NUMBER) FROM LOCAL STORAGE diff --git a/electron/utils/convert-and-scale.ts b/electron/utils/convert-and-scale.ts deleted file mode 100644 index 2d974ae..0000000 --- a/electron/utils/convert-and-scale.ts +++ /dev/null @@ -1,137 +0,0 @@ -import fs from "fs"; -import sharp, { FormatEnum, Metadata } from "sharp"; -import logit from "./logit"; -import { compression, customWidth } from "./config-variables"; -import { ImageFormat } from "./types"; - -const convertAndScale = async ( - originalImagePath: string, - upscaledImagePath: string, - processedImagePath: string, - scale: string, - saveImageAs: ImageFormat, - imageIsAlpha?: boolean, -) => { - // Skip conversion when the scale is 4x and compression is 0 - // - When output format is WebP or PNG - // - When the image is not alpha and the output format is JPEG - if ( - !customWidth && - (saveImageAs === "png" || saveImageAs === "webp") && - scale === "4" && - compression === 0 - ) { - logit("Skipping compression for 4x scale and 0% compression"); - return; - } else if ( - !customWidth && - saveImageAs === "jpg" && - scale === "4" && - compression === 0 && - !imageIsAlpha - ) { - logit("Skipping compression for 4x scale and 0% compression"); - return; - } - - let originalImage: Metadata | undefined; - - try { - originalImage = await sharp(originalImagePath).metadata(); - } catch (error) { - logit("❌ Error with original Image: ", error, " - ", originalImagePath); - } - - fs.access(originalImagePath, fs.constants.F_OK, (err) => { - logit("πŸ–ΌοΈ Checking if original image exists: ", originalImagePath); - if (err) { - throw new Error( - "Could not grab the original image from the path provided! - " + err, - ); - } - }); - - if (!originalImage) { - throw new Error("Could not grab the original image!"); - } - - // Convert compression percentage (0-100) to compressionLevel (0-9) - const compressionLevel = Math.round((compression / 100) * 9); - - logit( - "πŸ“ Processing Image: ", - JSON.stringify({ - originalWidth: originalImage.width, - originalHeight: originalImage.height, - customWidth, - scale, - saveImageAs, - compressionPercentage: compression, - compressionLevel, - }), - ); - - // Resize the image to the scale - const newImage = sharp(upscaledImagePath, { - limitInputPixels: false, - }) - .resize( - customWidth - ? parseInt(customWidth) - : originalImage.width && originalImage.width * parseInt(scale), - customWidth - ? null - : originalImage.height && originalImage.height * parseInt(scale), - ) - .withMetadata({ - density: originalImage.density, - orientation: originalImage.orientation, - }); - - const buffer = await newImage - .withMetadata({ - density: originalImage.density, - orientation: originalImage.orientation, - }) - .toBuffer(); - - try { - await sharp(buffer, { - limitInputPixels: false, - }) - .withMetadata({ - density: originalImage.density, - orientation: originalImage.orientation, - }) - .toFormat(saveImageAs as keyof FormatEnum, { - ...(saveImageAs === "jpg" && { - quality: 100 - (compression === 100 ? 99 : compression), - chromaSubsampling: "4:4:4", - }), - // 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, - }), - ...(saveImageAs === "webp" && { - quality: 100 - (compression === 100 ? 99 : compression), - alphaQuality: 100, - lossless: compression === 0, - smartSubsample: true, - }), - force: true, - }) - .toFile(processedImagePath); - } catch (error) { - logit("❌ Error converting to: ", saveImageAs, error); - } - - logit("βœ… Done converting to: ", upscaledImagePath); -}; - -export default convertAndScale; diff --git a/electron/utils/get-arguments.ts b/electron/utils/get-arguments.ts index 8f4e1f1..e4dce09 100644 --- a/electron/utils/get-arguments.ts +++ b/electron/utils/get-arguments.ts @@ -2,16 +2,25 @@ import { getPlatform } from "./get-device-specs"; import { ImageFormat } from "./types"; const slash: string = getPlatform() === "win" ? "\\" : "/"; -export const getSingleImageArguments = ( - inputDir: string, - fullfileName: string, - outFile: string, - modelsPath: string, - model: string, - scale: any, - gpuId: string, - saveImageAs: ImageFormat, -) => { +export const getSingleImageArguments = ({ + inputDir, + fullfileName, + outFile, + modelsPath, + model, + scale, + gpuId, + saveImageAs, +}: { + inputDir: string; + fullfileName: string; + outFile: string; + modelsPath: string; + model: string; + scale: any; + gpuId: string; + saveImageAs: ImageFormat; +}) => { return [ "-i", inputDir + slash + fullfileName, @@ -30,43 +39,25 @@ export const getSingleImageArguments = ( ]; }; -export const getSingleImageSharpenArguments = ( - inputDir: string, - fullfileName: string, - outFile: string, - modelsPath: string, - model: string, - scale: any, - gpuId: string, - saveImageAs: ImageFormat, -) => { - return [ - "-i", - inputDir + slash + fullfileName, - "-o", - outFile, - "-s", - scale, - "-x", - "-m", - modelsPath + slash + model, - gpuId ? "-g" : "", - gpuId ? gpuId : "", - "-f", - saveImageAs, - ]; -}; - -export const getDoubleUpscaleArguments = ( - inputDir: string, - fullfileName: string, - outFile: string, - modelsPath: string, - model: string, - gpuId: string, - saveImageAs: ImageFormat, - scale: string, -) => { +export const getDoubleUpscaleArguments = ({ + inputDir, + fullfileName, + outFile, + modelsPath, + model, + gpuId, + saveImageAs, + scale, +}: { + inputDir: string; + fullfileName: string; + outFile: string; + modelsPath: string; + model: string; + gpuId: string; + saveImageAs: ImageFormat; + scale: string; +}) => { return [ "-i", inputDir + slash + fullfileName, @@ -85,15 +76,23 @@ export const getDoubleUpscaleArguments = ( ]; }; -export const getDoubleUpscaleSecondPassArguments = ( - isAlpha: boolean, - outFile: string, - modelsPath: string, - model: string, - gpuId: string, - saveImageAs: ImageFormat, - scale: string, -) => { +export const getDoubleUpscaleSecondPassArguments = ({ + isAlpha, + outFile, + modelsPath, + model, + gpuId, + saveImageAs, + scale, +}: { + isAlpha: boolean; + outFile: string; + modelsPath: string; + model: string; + gpuId: string; + saveImageAs: ImageFormat; + scale: string; +}) => { return [ "-i", isAlpha ? outFile + ".png" : outFile, @@ -112,15 +111,23 @@ export const getDoubleUpscaleSecondPassArguments = ( ]; }; -export const getBatchArguments = ( - inputDir: string, - outputDir: string, - modelsPath: string, - model: string, - gpuId: string, - saveImageAs: ImageFormat, - scale: string, -) => { +export const getBatchArguments = ({ + inputDir, + outputDir, + modelsPath, + model, + gpuId, + saveImageAs, + scale, +}: { + inputDir: string; + outputDir: string; + modelsPath: string; + model: string; + gpuId: string; + saveImageAs: ImageFormat; + scale: string; +}) => { return [ "-i", inputDir, diff --git a/package-lock.json b/package-lock.json index 83d9d58..1f924b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "react-select": "^5.7.4", "react-tooltip": "^5.18.1", "remark-gfm": "^4.0.0", - "sharp": "^0.32.6", "tailwind-scrollbar": "^3.0.4", "theme-change": "^2.5.0" }, @@ -2132,11 +2131,6 @@ "postcss": "^8.1.0" } }, - "node_modules/b4a": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz", - "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==" - }, "node_modules/babel-plugin-macros": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", @@ -2169,6 +2163,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -2196,6 +2191,8 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "peer": true, "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -2278,6 +2275,7 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, "funding": [ { "type": "github", @@ -2639,18 +2637,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/color": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", - "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", - "dependencies": { - "color-convert": "^2.0.1", - "color-string": "^1.9.0" - }, - "engines": { - "node": ">=12.5.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2667,15 +2653,6 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, - "node_modules/color-string": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", - "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", - "dependencies": { - "color-name": "^1.0.0", - "simple-swizzle": "^0.2.2" - } - }, "node_modules/colord": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", @@ -2996,14 +2973,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/defer-to-connect": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", @@ -3060,14 +3029,6 @@ "node": ">=6" } }, - "node_modules/detect-libc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", - "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", - "engines": { - "node": ">=8" - } - }, "node_modules/detect-node": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", @@ -3554,14 +3515,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "engines": { - "node": ">=6" - } - }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -3613,11 +3566,6 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, - "node_modules/fast-fifo": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", - "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -3797,7 +3745,9 @@ "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "dev": true, + "peer": true }, "node_modules/fs-extra": { "version": "9.1.0", @@ -3902,11 +3852,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -4303,6 +4248,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, "funding": [ { "type": "github", @@ -4354,12 +4300,8 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/inline-style-parser": { "version": "0.2.2", @@ -5789,6 +5731,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5837,11 +5780,6 @@ "node": ">=10" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5874,11 +5812,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" - }, "node_modules/next": { "version": "13.5.6", "resolved": "https://registry.npmjs.org/next/-/next-13.5.6.tgz", @@ -5953,31 +5886,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/node-abi": { - "version": "3.54.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz", - "integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==", - "dependencies": { - "semver": "^7.3.5" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-abi/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/node-addon-api": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", @@ -6375,62 +6283,6 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, - "node_modules/prebuild-install": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", - "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/prebuild-install/node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" - }, - "node_modules/prebuild-install/node_modules/tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/prebuild-install/node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/prettier": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", @@ -6627,11 +6479,6 @@ } ] }, - "node_modules/queue-tick": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", - "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==" - }, "node_modules/quick-lru": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", @@ -6643,20 +6490,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, "node_modules/react": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", @@ -6808,6 +6641,8 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "peer": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -7098,47 +6933,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/sharp": { - "version": "0.32.6", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.32.6.tgz", - "integrity": "sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==", - "hasInstallScript": true, - "dependencies": { - "color": "^4.2.3", - "detect-libc": "^2.0.2", - "node-addon-api": "^6.1.0", - "prebuild-install": "^7.1.1", - "semver": "^7.5.4", - "simple-get": "^4.0.1", - "tar-fs": "^3.0.4", - "tunnel-agent": "^0.6.0" - }, - "engines": { - "node": ">=14.15.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/sharp/node_modules/node-addon-api": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", - "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" - }, - "node_modules/sharp/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -7163,62 +6957,6 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, - "node_modules/simple-swizzle": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", - "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", - "dependencies": { - "is-arrayish": "^0.3.1" - } - }, - "node_modules/simple-swizzle/node_modules/is-arrayish": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" - }, "node_modules/simple-update-notifier": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", @@ -7340,19 +7078,12 @@ "node": ">=10.0.0" } }, - "node_modules/streamx": { - "version": "2.15.6", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.6.tgz", - "integrity": "sha512-q+vQL4AAz+FdfT137VF69Cc/APqUbxy+MDOImRrMvchJpigHj9GksgDU2LYbO9rx7RX6osWgxJB2WxhYv4SZAw==", - "dependencies": { - "fast-fifo": "^1.1.0", - "queue-tick": "^1.0.1" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "peer": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -7428,14 +7159,6 @@ "node": ">=0.10.0" } }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/style-to-object": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-1.0.5.tgz", @@ -7646,26 +7369,6 @@ "node": ">=10" } }, - "node_modules/tar-fs": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz", - "integrity": "sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==", - "dependencies": { - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^3.1.5" - } - }, - "node_modules/tar-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", - "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", - "dependencies": { - "b4a": "^1.6.4", - "fast-fifo": "^1.2.0", - "streamx": "^2.15.0" - } - }, "node_modules/temp-file": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz", @@ -7793,17 +7496,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/type-fest": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", diff --git a/package.json b/package.json index 7e8fa8d..670b9bd 100644 --- a/package.json +++ b/package.json @@ -237,7 +237,6 @@ "react-select": "^5.7.4", "react-tooltip": "^5.18.1", "remark-gfm": "^4.0.0", - "sharp": "^0.32.6", "tailwind-scrollbar": "^3.0.4", "theme-change": "^2.5.0" }, diff --git a/renderer/atoms/userSettingsAtom.ts b/renderer/atoms/userSettingsAtom.ts index c6a487c..80b0ed5 100644 --- a/renderer/atoms/userSettingsAtom.ts +++ b/renderer/atoms/userSettingsAtom.ts @@ -5,9 +5,16 @@ export const customModelsPathAtom = atomWithStorage( "customModelsPath", null, ); + export const scaleAtom = atomWithStorage<"2" | "3" | "4">("scale", "4"); + export const batchModeAtom = atom(false); -export const outputPathAtom = atom(""); + +export const savedOutputPathAtom = atomWithStorage( + "savedOutputPath", + null, +); + export const progressAtom = atom(""); export const rememberOutputFolderAtom = atomWithStorage( diff --git a/renderer/components/settings-tab/CompressionInput.tsx b/renderer/components/settings-tab/CompressionInput.tsx index 536cd91..bd7027e 100644 --- a/renderer/components/settings-tab/CompressionInput.tsx +++ b/renderer/components/settings-tab/CompressionInput.tsx @@ -11,15 +11,10 @@ export function CompressionInput({

Image Compression ({compression}%)

-

- 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. + PNG compression is not supported at the moment.

)} -
-

CUSTOM OUTPUT WIDTH

-

- REQUIRES RESTART -
- Use a custom width for the output images. The height will be adjusted - automatically. Enabling this will override the scale setting. -

-
-
- { - if (!e.currentTarget.checked) { - localStorage.removeItem("customWidth"); - } - setUseCustomWidth(!useCustomWidth); - }} - /> - { - if (e.currentTarget.value === "") { - setUseCustomWidth(false); - setCustomWidth(null); - localStorage.removeItem("customWidth"); - return; - } - setCustomWidth(parseInt(e.currentTarget.value)); - }} - step="1" - className="input input-primary mt-2 w-full" - /> -
-
- ); -} diff --git a/renderer/components/settings-tab/ImageScaleSelect.tsx b/renderer/components/settings-tab/ImageScaleSelect.tsx index 9c73944..ee712d6 100644 --- a/renderer/components/settings-tab/ImageScaleSelect.tsx +++ b/renderer/components/settings-tab/ImageScaleSelect.tsx @@ -1,31 +1,22 @@ -import { useCustomWidthAtom } from "@/atoms/userSettingsAtom"; -import { useAtom } from "jotai"; -import React from "react"; - type ImageScaleSelectProps = { scale: "4" | "2" | "3"; setScale: (arg: "4" | "2" | "3") => void; }; export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) { - const [useCustomWidth, setUseCustomWidth] = useAtom(useCustomWidthAtom); - return ( -
+
-

- IMAGE SCALE {useCustomWidth && "DISABLED"} -

+

IMAGE SCALE ({scale}X)

{/*

EXPERIMENTAL

*/}
{ setScale(e.target.value.toString()); @@ -34,10 +25,11 @@ export function ImageScaleSelect({ scale, setScale }: ImageScaleSelectProps) { className="range range-primary mt-2" />
- 1x - 2x - 3x - 4x + 1 + 4 + 8 + 12 + 16
); diff --git a/renderer/components/settings-tab/ProcessImageToggle.tsx b/renderer/components/settings-tab/ProcessImageToggle.tsx deleted file mode 100644 index 4679f4b..0000000 --- a/renderer/components/settings-tab/ProcessImageToggle.tsx +++ /dev/null @@ -1,30 +0,0 @@ -type ProcessImageToggleProps = { - noImageProcessing: boolean; - setNoImageProcessing: (arg: any) => void; -}; - -const ProcessImageToggle = ({ - noImageProcessing, - setNoImageProcessing, -}: ProcessImageToggleProps) => { - return ( -
-

DON'T POST-PROCESS IMAGE

-

- If enabled, the image will not be converted or scaled or post-processed. - This will output the original AI upscaling result as-is. Use this if - you're having issues with file-size or color banding. -

- { - setNoImageProcessing(!noImageProcessing); - }} - /> -
- ); -}; - -export default ProcessImageToggle; diff --git a/renderer/components/settings-tab/SaveOutputFolderToggle.tsx b/renderer/components/settings-tab/SaveOutputFolderToggle.tsx index 0c76040..33e714e 100644 --- a/renderer/components/settings-tab/SaveOutputFolderToggle.tsx +++ b/renderer/components/settings-tab/SaveOutputFolderToggle.tsx @@ -1,20 +1,22 @@ -import React from "react"; +import { + savedOutputPathAtom, + rememberOutputFolderAtom, +} from "@/atoms/userSettingsAtom"; +import { useAtom } from "jotai"; -type SaveOutputFolderToggleProps = { - rememberOutputFolder: boolean; - setRememberOutputFolder: (arg: any) => void; -}; - -export function SaveOutputFolderToggle({ - rememberOutputFolder, - setRememberOutputFolder, -}: SaveOutputFolderToggleProps) { +export function SaveOutputFolderToggle() { + const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom); + const [rememberOutputFolder, setRememberOutputFolder] = useAtom( + rememberOutputFolderAtom, + ); return (

SAVE OUTPUT FOLDER

If enabled, the output folder will be remembered between sessions.

+ +

{outputPath}

{ setRememberOutputFolder((oldValue) => { if (oldValue === true) { - localStorage.removeItem("lastOutputFolderPath"); + setOutputPath(""); } return !oldValue; }); localStorage.setItem( "rememberOutputFolder", - JSON.stringify(!rememberOutputFolder) + JSON.stringify(!rememberOutputFolder), ); }} /> diff --git a/renderer/components/settings-tab/index.tsx b/renderer/components/settings-tab/index.tsx index 78f4921..934a1df 100644 --- a/renderer/components/settings-tab/index.tsx +++ b/renderer/components/settings-tab/index.tsx @@ -21,10 +21,8 @@ import { CompressionInput } from "./CompressionInput"; import OverwriteToggle from "./OverwriteToggle"; import { UpscaylCloudModal } from "../UpscaylCloudModal"; import { ResetSettings } from "./ResetSettings"; -import ProcessImageToggle from "./ProcessImageToggle"; import { featureFlags } from "@common/feature-flags"; import TurnOffNotificationsToggle from "./TurnOffNotificationsToggle"; -import { CustomResolutionInput } from "./CustomResolutionInput"; interface IProps { batchMode: boolean; @@ -65,7 +63,6 @@ function SettingsTab({ label: null, value: null, }); - const [rememberOutputFolder, setRememberOutputFolder] = useState(false); const [isCopied, setIsCopied] = useState(false); const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom); @@ -126,22 +123,6 @@ function SettingsTab({ setGpuId(currentlySavedGpuId); logit("βš™οΈ Getting gpuId from localStorage: ", currentlySavedGpuId); } - - if (!localStorage.getItem("rememberOutputFolder")) { - logit("βš™οΈ Setting rememberOutputFolder to false"); - localStorage.setItem("rememberOutputFolder", "false"); - } else { - const currentlySavedRememberOutputFolder = localStorage.getItem( - "rememberOutputFolder", - ); - logit( - "βš™οΈ Getting rememberOutputFolder from localStorage: ", - currentlySavedRememberOutputFolder, - ); - setRememberOutputFolder( - currentlySavedRememberOutputFolder === "true" ? true : false, - ); - } }, []); // HANDLERS @@ -210,29 +191,15 @@ function SettingsTab({ setExportType={setExportType} /> - + + - {!noImageProcessing && ( - <> - {/* IMAGE SCALE */} - - - - - - - )} - - + diff --git a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx index 1ea732f..4f34d94 100644 --- a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx +++ b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx @@ -7,18 +7,19 @@ import { modelsListAtom } from "../../../atoms/modelsListAtom"; import useLog from "../../hooks/useLog"; import { noImageProcessingAtom, - outputPathAtom, + savedOutputPathAtom, progressAtom, + rememberOutputFolderAtom, scaleAtom, } from "../../../atoms/userSettingsAtom"; import { featureFlags } from "@common/feature-flags"; import getModelScale from "@common/check-model-scale"; +import COMMAND from "@common/commands"; interface IProps { selectImageHandler: () => Promise; selectFolderHandler: () => Promise; handleModelChange: (e: any) => void; - outputHandler: () => Promise; upscaylHandler: () => Promise; batchMode: boolean; setBatchMode: React.Dispatch>; @@ -39,7 +40,6 @@ function LeftPaneImageSteps({ selectImageHandler, selectFolderHandler, handleModelChange, - outputHandler, upscaylHandler, batchMode, setBatchMode, @@ -63,14 +63,25 @@ function LeftPaneImageSteps({ const modelOptions = useAtomValue(modelsListAtom); const scale = useAtomValue(scaleAtom); const noImageProcessing = useAtomValue(noImageProcessingAtom); - const [outputPath, setOutputPath] = useAtom(outputPathAtom); + const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom); const [progress, setProgress] = useAtom(progressAtom); + const rememberOutputFolder = useAtomValue(rememberOutputFolderAtom); const [targetWidth, setTargetWidth] = useState(null); const [targetHeight, setTargetHeight] = useState(null); const { logit } = useLog(); + const outputHandler = async () => { + var path = await window.electron.invoke(COMMAND.SELECT_FOLDER); + if (path !== null) { + logit("πŸ—‚ Setting Output Path: ", path); + setOutputPath(path); + } else { + setOutputPath(null); + } + }; + useEffect(() => { themeChange(false); @@ -166,7 +177,9 @@ function LeftPaneImageSteps({ className="toggle" defaultChecked={batchMode} onClick={() => { - setOutputPath(""); + if (!rememberOutputFolder) { + setOutputPath(""); + } setProgress(""); setBatchMode((oldValue) => !oldValue); }} diff --git a/renderer/components/upscayl-tab/config/LeftPaneVideoSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneVideoSteps.tsx deleted file mode 100644 index 8343372..0000000 --- a/renderer/components/upscayl-tab/config/LeftPaneVideoSteps.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import React from "react"; -import Select from "react-select"; - -interface IProps { - progress: string; - selectVideoHandler: () => Promise; - handleModelChange: (e: any) => void; - handleDrop: (e: any) => void; - outputHandler: () => Promise; - upscaylHandler: () => Promise; - videoPath: string; - outputPath: string; - model: string; - isVideo: boolean; - setIsVideo: (arg: boolean) => void; -} - -function LeftPaneVideoSteps({ - progress, - selectVideoHandler, - handleModelChange, - handleDrop, - outputHandler, - upscaylHandler, - videoPath, - outputPath, - model, - isVideo, - setIsVideo, -}: IProps) { - const customStyles = { - option: (provided, state) => ({ - ...provided, - borderBottom: "1px dotted pink", - color: state.isSelected ? "red" : "blue", - padding: 20, - }), - control: () => ({ - // none of react-select's styles are passed to - width: 200, - }), - singleValue: (provided, state) => { - const opacity = state.isDisabled ? 0.5 : 1; - const transition = "opacity 300ms"; - - return { ...provided, opacity, transition }; - }, - }; - - const modelOptions = [ - { label: "2x Digital Art", value: "realesr-animevideov3-x2" }, - { label: "3x Digital Art", value: "realesr-animevideov3-x3" }, - { label: "4x Digital Art", value: "realesr-animevideov3-x4" }, - ]; - - return ( -
- {/* STEP 1 */} -
-

Step 1

- -
- - {/* STEP 2 */} -
-

Step 2

-

Select Scaling

- -