1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-28 01:10:52 +01:00

moved path replacement regex directly to image src's

This commit is contained in:
Yevgeniy Akimenko 2023-05-03 18:17:08 -07:00
parent 38ae8eb29a
commit d29e8600b3

View File

@ -124,7 +124,7 @@ const Home = () => {
// UPSCAYL DONE // UPSCAYL DONE
window.electron.on(commands.UPSCAYL_DONE, (_, data: string) => { window.electron.on(commands.UPSCAYL_DONE, (_, data: string) => {
setProgress(""); setProgress("");
setUpscaledImagePath(formatPath(data)); setUpscaledImagePath(data);
logit("upscaledImagePath: ", upscaledImagePath); logit("upscaledImagePath: ", upscaledImagePath);
logit(`📢 UPSCAYL_DONE: `, data); logit(`📢 UPSCAYL_DONE: `, data);
}); });
@ -140,7 +140,7 @@ const Home = () => {
window.electron.on(commands.DOUBLE_UPSCAYL_DONE, (_, data: string) => { window.electron.on(commands.DOUBLE_UPSCAYL_DONE, (_, data: string) => {
setProgress(""); setProgress("");
setDoubleUpscaylCounter(0); setDoubleUpscaylCounter(0);
setUpscaledImagePath(formatPath(data)); setUpscaledImagePath(data);
logit(`📢 DOUBLE_UPSCAYL_DONE: `, data); logit(`📢 DOUBLE_UPSCAYL_DONE: `, data);
}); });
@ -274,7 +274,7 @@ const Home = () => {
if (path !== null) { if (path !== null) {
logit("📢 Selected Image Path: ", path); logit("📢 Selected Image Path: ", path);
SetImagePath(formatPath(path)); SetImagePath(path);
var dirname = path.match(/(.*)[\/\\]/)[1] || ""; var dirname = path.match(/(.*)[\/\\]/)[1] || "";
logit("📢 Selected Image Directory: ", dirname); logit("📢 Selected Image Directory: ", dirname);
setOutputPath(dirname); setOutputPath(dirname);
@ -363,7 +363,7 @@ const Home = () => {
setVideoPath(filePath); setVideoPath(filePath);
} else { } else {
logit("📢 Setting image path: ", filePath); logit("📢 Setting image path: ", filePath);
SetImagePath(formatPath(filePath)); SetImagePath(filePath);
} }
var dirname = filePath.match(/(.*)[\/\\]/)[1] || ""; var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
@ -388,7 +388,7 @@ const Home = () => {
) { ) {
alert("Please drag and drop an image"); alert("Please drag and drop an image");
} else { } else {
SetImagePath(formatPath(filePath)); SetImagePath(filePath);
var dirname = filePath.match(/(.*)[\/\\]/)[1] || ""; var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
logit("📢 Setting output path: ", dirname); logit("📢 Setting output path: ", dirname);
setOutputPath(dirname); setOutputPath(dirname);
@ -687,7 +687,10 @@ const Home = () => {
</p> </p>
<img <img
src={"file:///" + imagePath} /* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
src={"file:///" + imagePath.replace(
/([^/\\]+)$/i,
encodeURIComponent(imagePath.match(/[^/\\]+$/i)[0]))}
alt="Original" alt="Original"
onMouseMove={handleMouseMove} onMouseMove={handleMouseMove}
style={{ style={{
@ -705,7 +708,10 @@ const Home = () => {
Upscayled Upscayled
</p> </p>
<img <img
src={"file://" + upscaledImagePath} /* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
src={"file://" + upscaledImagePath.replace(
/([^/\\]+)$/i,
encodeURIComponent(upscaledImagePath.match(/[^/\\]+$/i)[0]))}
alt="Upscayl" alt="Upscayl"
style={{ style={{
objectFit: "contain", objectFit: "contain",
@ -724,7 +730,11 @@ const Home = () => {
{isVideo && videoPath.length > 0 && upscaledVideoPath.length === 0 && ( {isVideo && videoPath.length > 0 && upscaledVideoPath.length === 0 && (
<video autoPlay controls className="m-10 w-11/12 rounded-2xl"> <video autoPlay controls className="m-10 w-11/12 rounded-2xl">
<source src={"file://" + videoPath} type="video/mp4" /> <source
src={"file://" + videoPath.replace(
/([^/\\]+)$/i,
encodeURIComponent(videoPath.match(/[^/\\]+$/i)[0]))}
type="video/mp4" />
</video> </video>
)} )}
</div> </div>