mirror of
https://github.com/upscayl/upscayl.git
synced 2024-09-24 03:18:28 +02:00
Fix batch upscayl
This commit is contained in:
parent
a6c9c5a20d
commit
f08671c357
@ -54,26 +54,18 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
}
|
||||
const desiredScale = payload.scale as string;
|
||||
|
||||
const tempDirectory = outputDir + slash + "upscayl_temp";
|
||||
outputDir +=
|
||||
slash +
|
||||
`upscayl_${model}_x${noImageProcessing ? initialScale : desiredScale}`;
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
// Create a folder in the output directory to store the original images
|
||||
if (!fs.existsSync(tempDirectory)) {
|
||||
fs.mkdirSync(tempDirectory, { recursive: true });
|
||||
}
|
||||
// Copy the files from the input directory to the output directory
|
||||
|
||||
// Delete .DS_Store files
|
||||
fs.readdirSync(inputDir).forEach((file) => {
|
||||
if (
|
||||
file.toLocaleLowerCase().endsWith(".png") ||
|
||||
file.toLocaleLowerCase().endsWith(".jpg") ||
|
||||
file.toLocaleLowerCase().endsWith(".jpeg") ||
|
||||
file.toLocaleLowerCase().endsWith(".webp")
|
||||
) {
|
||||
fs.copyFileSync(inputDir + slash + file, tempDirectory + slash + file);
|
||||
if (file === ".DS_Store") {
|
||||
logit("🗑️ Deleting .DS_Store file");
|
||||
fs.unlinkSync(inputDir + slash + file);
|
||||
}
|
||||
});
|
||||
|
||||
@ -81,7 +73,7 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
const upscayl = spawnUpscayl(
|
||||
"realesrgan",
|
||||
getBatchArguments(
|
||||
tempDirectory,
|
||||
inputDir,
|
||||
outputDir,
|
||||
isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
|
||||
model,
|
||||
@ -137,51 +129,28 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
logit("🚫 Skipping scaling and converting");
|
||||
mainWindow.setProgressBar(-1);
|
||||
mainWindow.webContents.send(COMMAND.FOLDER_UPSCAYL_DONE, outputDir);
|
||||
rmdir(
|
||||
tempDirectory,
|
||||
{
|
||||
recursive: true,
|
||||
},
|
||||
(err) => {
|
||||
if (err) {
|
||||
logit("🚫 Error deleting temp folder", err);
|
||||
}
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(tempDirectory);
|
||||
const files = fs.readdirSync(inputDir);
|
||||
try {
|
||||
files.forEach(async (file) => {
|
||||
console.log("Filename: ", file.slice(0, -3));
|
||||
await convertAndScale(
|
||||
tempDirectory + slash + file,
|
||||
inputDir + slash + file,
|
||||
outputDir + slash + file.slice(0, -3) + "png",
|
||||
outputDir + slash + file.slice(0, -3) + saveImageAs,
|
||||
desiredScale,
|
||||
saveImageAs,
|
||||
onError
|
||||
);
|
||||
});
|
||||
files.forEach(async (file) => {
|
||||
// Remove the png file (default) if the saveImageAs is not png
|
||||
if (saveImageAs !== "png") {
|
||||
logit("Removing output PNG");
|
||||
fs.unlinkSync(outputDir + slash + file.slice(0, -3) + "png");
|
||||
}
|
||||
});
|
||||
mainWindow.webContents.send(COMMAND.FOLDER_UPSCAYL_DONE, outputDir);
|
||||
rmdir(
|
||||
tempDirectory,
|
||||
{
|
||||
recursive: true,
|
||||
},
|
||||
(err) => {
|
||||
if (err) {
|
||||
logit("🚫 Error deleting temp folder", err);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
logit("❌ Error processing (scaling and converting) the image.", error);
|
||||
upscayl.kill();
|
||||
|
6
mas.json
6
mas.json
@ -2,9 +2,9 @@
|
||||
"productName": "Upscayl",
|
||||
"appId": "org.upscayl.Upscayl",
|
||||
"afterSign": "./notarize.js",
|
||||
"buildVersion": "23.11.5",
|
||||
"buildVersion": "23.12.03",
|
||||
"asar": true,
|
||||
"asarUnpack": ["**/node_modules/sharp/**/*"],
|
||||
"asarUnpack": ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"],
|
||||
"extraFiles": [
|
||||
{
|
||||
"from": "resources/${os}/bin",
|
||||
@ -25,6 +25,8 @@
|
||||
"entitlements": "resources/entitlements.mas.plist",
|
||||
"entitlementsInherit": "resources/entitlements.mas.inherit.plist",
|
||||
"provisioningProfile": "embedded.provisionprofile",
|
||||
"icon": "build/icon.icns",
|
||||
"x64ArchFiles": "*",
|
||||
"target": [
|
||||
{
|
||||
"target": "mas",
|
||||
|
1493
package-lock.json
generated
1493
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "upscayl",
|
||||
"private": true,
|
||||
"version": "2.9.4",
|
||||
"version": "2.9.5",
|
||||
"productName": "Upscayl",
|
||||
"author": {
|
||||
"name": "Nayam Amarshe",
|
||||
@ -232,6 +232,8 @@
|
||||
"firebase": "^10.3.0",
|
||||
"gray-matter": "^4.0.3",
|
||||
"jotai": "^2.2.2",
|
||||
"node-addon-api": "^7.0.0",
|
||||
"node-gyp": "^10.0.1",
|
||||
"react-compare-slider": "^2.2.0",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-select": "^5.7.4",
|
||||
@ -242,6 +244,6 @@
|
||||
"theme-change": "^2.5.0"
|
||||
},
|
||||
"volta": {
|
||||
"node": "16.17.0"
|
||||
"node": "18.17.0"
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +219,9 @@ const Home = () => {
|
||||
|
||||
// FETCH NEWS
|
||||
useEffect(() => {
|
||||
// TODO: Disable on no internet
|
||||
try {
|
||||
return;
|
||||
fetch("https://raw.githubusercontent.com/upscayl/upscayl/main/news.md", {
|
||||
cache: "no-cache",
|
||||
})
|
||||
@ -233,11 +236,9 @@ const Home = () => {
|
||||
}
|
||||
const markdownData = matter(newsData);
|
||||
if (!markdownData) return;
|
||||
|
||||
if (markdownData && markdownData.data.dontShow) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
markdownData &&
|
||||
news &&
|
||||
@ -252,6 +253,9 @@ const Home = () => {
|
||||
setShowNewsModal(true);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Could not fetch Upscayl News");
|
||||
}
|
||||
}, [news]);
|
||||
|
||||
// CONFIGURE SAVED OUTPUT PATH
|
||||
|
Loading…
Reference in New Issue
Block a user