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