mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
Fix image
This commit is contained in:
parent
53c3ac3aed
commit
8759f29798
@ -5,14 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { join, dirname, resolve } from "path";
|
import { join, dirname, resolve } from "path";
|
||||||
import getPlatform from "./getPlatform";
|
import { getArch, getPlatform } from "./getDeviceSpecs";
|
||||||
import isDev from "electron-is-dev";
|
import isDev from "electron-is-dev";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
|
||||||
const appRootDir = app.getAppPath();
|
const appRootDir = app.getAppPath();
|
||||||
|
|
||||||
const binariesPath = isDev
|
const binariesPath = isDev
|
||||||
? join(appRootDir, "resources", getPlatform()!, "bin")
|
? join(appRootDir, "resources", getPlatform()!, getArch()!, "bin")
|
||||||
: join(dirname(appRootDir), "bin");
|
: join(dirname(appRootDir), "bin");
|
||||||
|
|
||||||
const execPath = (execName) =>
|
const execPath = (execName) =>
|
||||||
|
32
electron/getDeviceSpecs.ts
Normal file
32
electron/getDeviceSpecs.ts
Normal 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";
|
||||||
|
}
|
||||||
|
};
|
@ -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;
|
|
@ -1,6 +1,6 @@
|
|||||||
// Native
|
// Native
|
||||||
import { autoUpdater } from "electron-updater";
|
import { autoUpdater } from "electron-updater";
|
||||||
import getPlatform from "./getPlatform";
|
import { getPlatform } from "./getDeviceSpecs";
|
||||||
import { join, parse } from "path";
|
import { join, parse } from "path";
|
||||||
import log from "electron-log";
|
import log from "electron-log";
|
||||||
import { format } from "url";
|
import { format } from "url";
|
||||||
@ -61,7 +61,7 @@ let mainWindow: BrowserWindow | null = null;
|
|||||||
app.on("ready", async () => {
|
app.on("ready", async () => {
|
||||||
await prepareNext("./renderer");
|
await prepareNext("./renderer");
|
||||||
|
|
||||||
log.info("🚀 UPSCAYL EXEC PATH: ", execPath(""));
|
log.info("🚀 UPSCAYL EXEC PATH: ", execPath("realesrgan"));
|
||||||
log.info("🚀 MODELS PATH: ", modelsPath);
|
log.info("🚀 MODELS PATH: ", modelsPath);
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ipcRenderer, contextBridge } from "electron";
|
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'
|
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
|
||||||
contextBridge.exposeInMainWorld("electron", {
|
contextBridge.exposeInMainWorld("electron", {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import getPlatform from "../getPlatform";
|
import { getPlatform } from "../getDeviceSpecs";
|
||||||
const slash: string = getPlatform() === "win" ? "\\" : "/";
|
const slash: string = getPlatform() === "win" ? "\\" : "/";
|
||||||
|
|
||||||
export const getSingleImageArguments = (
|
export const getSingleImageArguments = (
|
||||||
|
@ -54,12 +54,11 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"productName": "Upscayl",
|
"productName": "Upscayl",
|
||||||
"appId": "org.upscayl.app",
|
"appId": "org.upscayl.app",
|
||||||
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
|
"artifactName": "${name}-${version}-${os}.${ext}",
|
||||||
"asar": true,
|
"asar": true,
|
||||||
"afterSign": "scripts/notarize.js",
|
|
||||||
"extraFiles": [
|
"extraFiles": [
|
||||||
{
|
{
|
||||||
"from": "resources/${os}/${arch}/bin",
|
"from": "resources/${os}/bin",
|
||||||
"to": "resources/bin",
|
"to": "resources/bin",
|
||||||
"filter": [
|
"filter": [
|
||||||
"**/*"
|
"**/*"
|
||||||
|
@ -107,7 +107,6 @@ function LeftPaneImageSteps({
|
|||||||
}, [currentModel]);
|
}, [currentModel]);
|
||||||
|
|
||||||
const getUpscaleResolution = useCallback(() => {
|
const getUpscaleResolution = useCallback(() => {
|
||||||
console.log("running");
|
|
||||||
const newDimensions = {
|
const newDimensions = {
|
||||||
width: dimensions.width,
|
width: dimensions.width,
|
||||||
height: dimensions.height,
|
height: dimensions.height,
|
||||||
|
@ -24,8 +24,12 @@ import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
|
|||||||
const Home = () => {
|
const Home = () => {
|
||||||
// STATES
|
// STATES
|
||||||
const [os, setOs] = useState<"linux" | "mac" | "win" | undefined>(undefined);
|
const [os, setOs] = useState<"linux" | "mac" | "win" | undefined>(undefined);
|
||||||
const [imagePath, SetImagePath] = useState("");
|
const [imagePath, SetImagePath] = useState(
|
||||||
const [upscaledImagePath, setUpscaledImagePath] = 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 [outputPath, setOutputPath] = useState("");
|
||||||
const [scaleFactor] = useState(4);
|
const [scaleFactor] = useState(4);
|
||||||
const [progress, setProgress] = useState("");
|
const [progress, setProgress] = useState("");
|
||||||
@ -106,6 +110,8 @@ const Home = () => {
|
|||||||
window.electron.on(commands.UPSCAYL_PROGRESS, (_, data: string) => {
|
window.electron.on(commands.UPSCAYL_PROGRESS, (_, data: string) => {
|
||||||
if (data.length > 0 && data.length < 10) {
|
if (data.length > 0 && data.length < 10) {
|
||||||
setProgress(data);
|
setProgress(data);
|
||||||
|
} else if (data.includes("converting")) {
|
||||||
|
setProgress("Scaling and converting image...");
|
||||||
}
|
}
|
||||||
handleErrors(data);
|
handleErrors(data);
|
||||||
logit(`🚧 UPSCAYL_PROGRESS: `, data);
|
logit(`🚧 UPSCAYL_PROGRESS: `, data);
|
||||||
@ -645,13 +651,7 @@ const Home = () => {
|
|||||||
|
|
||||||
<img
|
<img
|
||||||
/* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
|
/* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
|
||||||
src={
|
src={"file:///" + imagePath}
|
||||||
"file:///" +
|
|
||||||
imagePath.replace(
|
|
||||||
/([^/\\]+)$/i,
|
|
||||||
encodeURIComponent(imagePath.match(/[^/\\]+$/i)[0])
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt="Original"
|
alt="Original"
|
||||||
onMouseMove={handleMouseMove}
|
onMouseMove={handleMouseMove}
|
||||||
style={{
|
style={{
|
||||||
@ -670,15 +670,10 @@ const Home = () => {
|
|||||||
</p>
|
</p>
|
||||||
<img
|
<img
|
||||||
/* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
|
/* USE REGEX TO GET THE FILENAME AND ENCODE IT INTO PROPER FORM IN ORDER TO AVOID ERRORS DUE TO SPECIAL CHARACTERS */
|
||||||
src={
|
src={"file:///" + upscaledImagePath}
|
||||||
"file://" +
|
onChange={(e) => {
|
||||||
upscaledImagePath.replace(
|
console.log(e.currentTarget);
|
||||||
/([^/\\]+)$/i,
|
}}
|
||||||
encodeURIComponent(
|
|
||||||
upscaledImagePath.match(/[^/\\]+$/i)[0]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alt="Upscayl"
|
alt="Upscayl"
|
||||||
style={{
|
style={{
|
||||||
objectFit: "contain",
|
objectFit: "contain",
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user