import { useState, useEffect, useRef } from "react"; import commands from "../../constants/commands"; import { ReactCompareSlider, ReactCompareSliderImage, } from "react-compare-slider"; const Home = () => { const [imagePath, SetImagePath] = useState(""); const [upscaledImagePath, setUpscaledImagePath] = useState(""); const [outputPath, SetOutputPath] = useState(""); const [scaleFactor, setScaleFactor] = useState(4); const [progress, setProgress] = useState(""); const [model, setModel] = useState("realesrgan-x4plus"); const [loaded, setLoaded] = useState(false); useEffect(() => { setLoaded(true); window.electron.on(commands.UPSCAYL_PROGRESS, (_, data) => { if (data.length > 0 && data.length < 10) setProgress(data); }); window.electron.on(commands.UPSCAYL_DONE, (_, data) => { setUpscaledImagePath(data); }); }, []); const selectImageHandler = async () => { SetImagePath(""); setUpscaledImagePath(""); setProgress(""); var path = await window.electron.invoke(commands.SELECT_FILE); if (path !== "cancelled") { SetImagePath(path); var dirname = path.match(/(.*)[\/\\]/)[1] || ""; SetOutputPath(dirname); } }; const outputHandler = async () => { var path = await window.electron.invoke(commands.SELECT_FOLDER); if (path !== "cancelled") { SetOutputPath(path); } else { console.log("Getting output path from input file"); } }; const upscaylHandler = async () => { setProgress("0.00%"); await window.electron.send(commands.UPSCAYL, { scaleFactor, imagePath, outputPath, model, }); }; useEffect(() => { console.log(progress); }, [progress]); return (
{/* HEADER */}

Upscayl

AI Image Upscaler

{/* LEFT PANE */}
{/* STEP 1 */}

Step 1

{/* STEP 2 */}

Step 2

Select Scale Factor

{/* STEP 3 */}

Step 3

Defaults to Image's path

{/* STEP 4 */}

Step 4

Copyright © 2022 -{" "} Upscayl

Made by{" "} TGS963 {" "} and{" "} Nayam Amarshe

{/* RIGHT PANE */}
{progress.length > 0 && (
Loading

{progress}

)} {imagePath.length === 0 ? (

Select an Image to Upscale

) : upscaledImagePath.length === 0 ? ( ) : ( } itemTwo={ } className="h-full" /> )}
); }; export default Home;