1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-30 18:24:27 +01:00
upscayl/electron/utils/get-arguments.ts
2024-04-21 22:44:39 +05:30

151 lines
2.5 KiB
TypeScript

import { getPlatform } from "./get-device-specs";
import { ImageFormat } from "./types";
const slash: string = getPlatform() === "win" ? "\\" : "/";
export const getSingleImageArguments = ({
inputDir,
fullfileName,
outFile,
modelsPath,
model,
scale,
gpuId,
saveImageAs,
customWidth,
}: {
inputDir: string;
fullfileName: string;
outFile: string;
modelsPath: string;
model: string;
scale: any;
gpuId: string;
saveImageAs: ImageFormat;
customWidth: string;
}) => {
return [
"-i",
inputDir + slash + fullfileName,
"-o",
outFile,
customWidth ? "" : `-s ${scale}`,
"-m",
modelsPath,
"-n",
model,
gpuId ? `-g ${gpuId}` : "",
"-f",
saveImageAs,
customWidth ? `-w ${customWidth}` : "",
];
};
export const getDoubleUpscaleArguments = ({
inputDir,
fullfileName,
outFile,
modelsPath,
model,
gpuId,
saveImageAs,
scale,
customWidth,
}: {
inputDir: string;
fullfileName: string;
outFile: string;
modelsPath: string;
model: string;
gpuId: string;
saveImageAs: ImageFormat;
scale: string;
customWidth: string;
}) => {
return [
"-i",
inputDir + slash + fullfileName,
"-o",
outFile,
customWidth ? "" : `-s ${scale}`,
"-m",
modelsPath,
"-n",
model,
gpuId ? `-g ${gpuId}` : "",
"-f",
saveImageAs,
customWidth ? `-w ${customWidth}` : "",
];
};
export const getDoubleUpscaleSecondPassArguments = ({
outFile,
modelsPath,
model,
gpuId,
saveImageAs,
scale,
customWidth,
}: {
outFile: string;
modelsPath: string;
model: string;
gpuId: string;
saveImageAs: ImageFormat;
scale: string;
customWidth: string;
}) => {
return [
"-i",
outFile,
"-o",
outFile,
"-s",
customWidth ? "" : `-s ${scale}`,
"-m",
modelsPath,
"-n",
model,
gpuId ? `-g ${gpuId}` : "",
"-f",
saveImageAs,
customWidth ? `-w ${customWidth}` : "",
];
};
export const getBatchArguments = ({
inputDir,
outputDir,
modelsPath,
model,
gpuId,
saveImageAs,
scale,
customWidth,
}: {
inputDir: string;
outputDir: string;
modelsPath: string;
model: string;
gpuId: string;
saveImageAs: ImageFormat;
scale: string;
customWidth: string;
}) => {
return [
"-i",
inputDir,
"-o",
outputDir,
customWidth ? "" : `-s ${scale}`,
"-m",
modelsPath,
"-n",
model,
gpuId ? `-g ${gpuId}` : "",
"-f",
saveImageAs,
customWidth ? `-w ${customWidth}` : "",
];
};