mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-23 23:21:05 +01:00
implemented working batch mode frontend
This commit is contained in:
parent
313a7db4cb
commit
d2abeb1f13
@ -223,7 +223,6 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
const scale = payload.scaleFactor;
|
||||
let inputDir = payload.imagePath.match(/(.*)[\/\\]/)[1] || "";
|
||||
let outputDir = payload.outputPath;
|
||||
console.log(outputDir);
|
||||
|
||||
// COPY IMAGE TO TMP FOLDER
|
||||
const platform = getPlatform();
|
||||
@ -293,10 +292,12 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
//------------------------Upscayl Folder-----------------------------//
|
||||
ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
const model = payload.model;
|
||||
let inputDir = payload.imagePath;
|
||||
let inputDir = payload.batchFolderPath;
|
||||
let outputDir = payload.outputPath;
|
||||
console.log(outputDir);
|
||||
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
// UPSCALE
|
||||
let upscayl = spawn(
|
||||
execPath("realesrgan"),
|
||||
@ -336,7 +337,7 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
upscayl.on("close", (code) => {
|
||||
if (failed !== true) {
|
||||
console.log("Done upscaling");
|
||||
mainWindow.webContents.send(commands.FOLDER_UPSCAYL_DONE, outFile);
|
||||
mainWindow.webContents.send(commands.FOLDER_UPSCAYL_DONE, outputDir);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -21,6 +21,7 @@ const Home = () => {
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [version, setVersion] = useState("");
|
||||
const [batchMode, setBatchMode] = useState(false);
|
||||
const [batchFolderPath, setBatchFolderPath] = useState("");
|
||||
const [doubleUpscayl, setDoubleUpscayl] = useState(false);
|
||||
|
||||
const resetImagePaths = () => {
|
||||
@ -90,6 +91,14 @@ const Home = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const selectFolderHandler = async () => {
|
||||
var path = await window.electron.invoke(commands.SELECT_FOLDER);
|
||||
if (path !== "cancelled") {
|
||||
setBatchFolderPath(path);
|
||||
SetOutputPath(path + "_upscayled");
|
||||
}
|
||||
};
|
||||
|
||||
const handleModelChange = (e) => {
|
||||
setModel(e.target.value);
|
||||
};
|
||||
@ -164,7 +173,7 @@ const Home = () => {
|
||||
|
||||
const upscaylHandler = async () => {
|
||||
setUpscaledImagePath("");
|
||||
if (imagePath !== "") {
|
||||
if (imagePath !== "" || batchFolderPath !== "") {
|
||||
setProgress("Hold on...");
|
||||
if (model === "models-DF2K") {
|
||||
setDoubleUpscayl(false);
|
||||
@ -176,6 +185,13 @@ const Home = () => {
|
||||
outputPath,
|
||||
model,
|
||||
});
|
||||
} else if (batchMode) {
|
||||
await window.electron.send(commands.FOLDER_UPSCAYL, {
|
||||
scaleFactor,
|
||||
batchFolderPath,
|
||||
outputPath,
|
||||
model,
|
||||
});
|
||||
} else {
|
||||
await window.electron.send(commands.UPSCAYL, {
|
||||
scaleFactor,
|
||||
@ -202,6 +218,7 @@ const Home = () => {
|
||||
<LeftPaneSteps
|
||||
progress={progress}
|
||||
selectImageHandler={selectImageHandler}
|
||||
selectFolderHandler={selectFolderHandler}
|
||||
handleModelChange={handleModelChange}
|
||||
handleDrop={handleDrop}
|
||||
outputHandler={outputHandler}
|
||||
@ -231,7 +248,7 @@ const Home = () => {
|
||||
<ProgressBar progress={progress} />
|
||||
)}
|
||||
|
||||
{imagePath.length === 0 ? (
|
||||
{imagePath.length === 0 && batchFolderPath.length === 0 ? (
|
||||
<RightPaneInfo version={version} />
|
||||
) : upscaledImagePath.length === 0 ? (
|
||||
<img
|
||||
@ -242,7 +259,7 @@ const Home = () => {
|
||||
draggable="false"
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
) : !batchMode ? (
|
||||
<ReactCompareSlider
|
||||
itemOne={
|
||||
<ReactCompareSliderImage
|
||||
@ -264,7 +281,7 @@ const Home = () => {
|
||||
}
|
||||
className="h-screen"
|
||||
/>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user