1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-18 02:16:01 +01:00

Fix image

This commit is contained in:
Nayam Amarshe 2023-09-04 21:29:17 +05:30
parent 53c3ac3aed
commit 8759f29798
13 changed files with 53 additions and 49 deletions

View File

@ -5,14 +5,14 @@
*/
import { join, dirname, resolve } from "path";
import getPlatform from "./getPlatform";
import { getArch, getPlatform } from "./getDeviceSpecs";
import isDev from "electron-is-dev";
import { app } from "electron";
const appRootDir = app.getAppPath();
const binariesPath = isDev
? join(appRootDir, "resources", getPlatform()!, "bin")
? join(appRootDir, "resources", getPlatform()!, getArch()!, "bin")
: join(dirname(appRootDir), "bin");
const execPath = (execName) =>

View File

@ -0,0 +1,32 @@
"use strict";
import { platform, arch } from "os";
export const getPlatform = () => {
switch (platform()) {
case "aix":
case "freebsd":
case "linux":
case "openbsd":
case "android":
return "linux";
case "darwin":
case "sunos":
return "mac";
case "win32":
return "win";
}
};
export const getArch = () => {
switch (arch()) {
case "x64":
return "x64";
case "x32":
return "x86";
case "arm":
return "arm";
case "arm64":
return "arm64";
}
};

View File

@ -1,21 +0,0 @@
"use strict";
import { platform } from "os";
const getPlatform = () => {
switch (platform()) {
case "aix":
case "freebsd":
case "linux":
case "openbsd":
case "android":
return "linux";
case "darwin":
case "sunos":
return "mac";
case "win32":
return "win";
}
};
export default getPlatform;

View File

@ -1,6 +1,6 @@
// Native
import { autoUpdater } from "electron-updater";
import getPlatform from "./getPlatform";
import { getPlatform } from "./getDeviceSpecs";
import { join, parse } from "path";
import log from "electron-log";
import { format } from "url";
@ -61,7 +61,7 @@ let mainWindow: BrowserWindow | null = null;
app.on("ready", async () => {
await prepareNext("./renderer");
log.info("🚀 UPSCAYL EXEC PATH: ", execPath(""));
log.info("🚀 UPSCAYL EXEC PATH: ", execPath("realesrgan"));
log.info("🚀 MODELS PATH: ", modelsPath);
mainWindow = new BrowserWindow({

View File

@ -1,5 +1,5 @@
import { ipcRenderer, contextBridge } from "electron";
import getPlatform from "./getPlatform";
import { getPlatform } from "./getDeviceSpecs";
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
contextBridge.exposeInMainWorld("electron", {

View File

@ -1,4 +1,4 @@
import getPlatform from "../getPlatform";
import { getPlatform } from "../getDeviceSpecs";
const slash: string = getPlatform() === "win" ? "\\" : "/";
export const getSingleImageArguments = (

View File

@ -54,12 +54,11 @@
"build": {
"productName": "Upscayl",
"appId": "org.upscayl.app",
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
"artifactName": "${name}-${version}-${os}.${ext}",
"asar": true,
"afterSign": "scripts/notarize.js",
"extraFiles": [
{
"from": "resources/${os}/${arch}/bin",
"from": "resources/${os}/bin",
"to": "resources/bin",
"filter": [
"**/*"

View File

@ -107,7 +107,6 @@ function LeftPaneImageSteps({
}, [currentModel]);
const getUpscaleResolution = useCallback(() => {
console.log("running");
const newDimensions = {
width: dimensions.width,
height: dimensions.height,

View File

@ -24,8 +24,12 @@ import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
const Home = () => {
// STATES
const [os, setOs] = useState<"linux" | "mac" | "win" | undefined>(undefined);
const [imagePath, SetImagePath] = useState("");
const [upscaledImagePath, setUpscaledImagePath] = useState("");
const [imagePath, SetImagePath] = useState(
"/Users/macbook-air/Downloads/wp9454111_upscayl_4x_realesrgan-x4plus.png"
);
const [upscaledImagePath, setUpscaledImagePath] = useState(
"/Users/macbook-air/Downloads/wp9454111_upscayl_4x_realesrgan-x4plus.png"
);
const [outputPath, setOutputPath] = useState("");
const [scaleFactor] = useState(4);
const [progress, setProgress] = useState("");
@ -106,6 +110,8 @@ const Home = () => {
window.electron.on(commands.UPSCAYL_PROGRESS, (_, data: string) => {
if (data.length > 0 && data.length < 10) {
setProgress(data);
} else if (data.includes("converting")) {
setProgress("Scaling and converting image...");
}
handleErrors(data);
logit(`🚧 UPSCAYL_PROGRESS: `, data);
@ -645,13 +651,7 @@ const Home = () => {
<img
/* 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])
)
}
src={"file:///" + imagePath}
alt="Original"
onMouseMove={handleMouseMove}
style={{
@ -670,15 +670,10 @@ const Home = () => {
</p>
<img
/* 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]
)
)
}
src={"file:///" + upscaledImagePath}
onChange={(e) => {
console.log(e.currentTarget);
}}
alt="Upscayl"
style={{
objectFit: "contain",