waifu2x
Version:
2x upscaling of images with waifu2x
105 lines (104 loc) • 5.42 kB
TypeScript
import { ChildProcess } from "child_process";
export type Waifu2xFormats = "bmp" | "dib" | "exr" | "hdr" | "jpe" | "jpeg" | "jpg" | "pbm" | "pgm" | "pic" | "png" | "pnm" | "ppm" | "pxm" | "ras" | "sr" | "tif" | "tiff" | "webp";
export interface Waifu2xOptions {
upscaler?: "waifu2x" | "real-esrgan" | "real-cugan" | "anime4k" | string;
noise?: -1 | 0 | 1 | 2 | 3;
scale?: number;
mode?: "noise" | "scale" | "noise-scale";
pngCompression?: number;
jpgWebpQuality?: number;
threads?: number;
recursive?: boolean;
rename?: string;
limit?: number;
parallelFrames?: number;
waifu2xPath?: string;
waifu2xModel?: "models-cunet" | "models-upconv_7_anime_style_art_rgb";
webpPath?: string;
esrganPath?: string;
cuganPath?: string;
anime4kPath?: string;
scriptsPath?: string;
rifePath?: string;
rifeModel?: string;
pythonDownscale?: number;
}
export interface Waifu2xGIFOptions extends Waifu2xOptions {
quality?: number;
speed?: number;
reverse?: boolean;
transparentColor?: string;
noResume?: boolean;
pngFrames?: boolean;
}
export interface Waifu2xAnimatedWebpOptions extends Waifu2xOptions {
quality?: number;
speed?: number;
reverse?: boolean;
noResume?: boolean;
}
export interface Waifu2xVideoOptions extends Waifu2xOptions {
framerate?: number;
quality?: number;
speed?: number;
reverse?: boolean;
pitch?: boolean;
sdColorSpace?: boolean;
noResume?: boolean;
pngFrames?: boolean;
fpsMultiplier?: number;
ffmpegPath?: string;
}
export interface Waifu2xPDFOptions extends Waifu2xOptions {
quality?: number;
reverse?: boolean;
noResume?: boolean;
pngFrames?: boolean;
downscaleHeight?: number;
}
export default class Waifu2x {
static processes: ChildProcess[];
private static addProcess;
private static removeProcess;
static chmod777: (waifu2xPath?: string, webpPath?: string, esrganPath?: string, cuganPath?: string, anime4kPath?: string, rifePath?: string) => void;
private static parseFilename;
private static recursiveRename;
static parseDest: (source: string, dest?: string, options?: {
rename?: string;
}) => string;
private static timeout;
static convertToWebp: (source: string, dest: string, webpPath?: string, quality?: number) => Promise<string>;
static convertFromWebp: (source: string, dest: string, webpPath?: string) => Promise<string>;
static upscaleImage: (source: string, dest?: string, options?: Waifu2xOptions, progress?: (percent?: number) => void | boolean) => Promise<string>;
private static searchFiles;
static upscaleImages: (sourceFolder: string, destFolder?: string, options?: Waifu2xOptions, progress?: (current: number, total: number) => void | boolean) => Promise<string[]>;
private static parseTransparentColor;
private static encodeGIF;
private static awaitStream;
private static newDest;
private static findMatchingSettings;
static upscaleGIF: (source: string, dest?: string, options?: Waifu2xGIFOptions, progress?: (current: number, total: number) => void | boolean) => Promise<string>;
static upscaleGIFs: (sourceFolder: string, destFolder?: string, options?: Waifu2xGIFOptions, totalProgress?: (current: number, total: number) => void | boolean, progress?: (current: number, total: number) => void | boolean) => Promise<string[]>;
private static dumpWebpFrames;
private static parseWebpDelays;
private static encodeAnimatedWebp;
static upscaleAnimatedWebp: (source: string, dest?: string, options?: Waifu2xGIFOptions, progress?: (current: number, total: number) => void | boolean) => Promise<string>;
static upscaleAnimatedWebps: (sourceFolder: string, destFolder?: string, options?: Waifu2xAnimatedWebpOptions, totalProgress?: (current: number, total: number) => void | boolean, progress?: (current: number, total: number) => void | boolean) => Promise<string[]>;
static parseFramerate: (file: string, ffmpegPath?: string) => Promise<number>;
static parseDuration: (file: string, ffmpegPath?: string) => Promise<any>;
static parseResolution: (file: string, ffmpegPath?: string) => Promise<{
width: number;
height: number;
}>;
static upscaleVideo: (source: string, dest?: string, options?: Waifu2xVideoOptions, progress?: (current: number, total: number) => void | boolean, interlopProgress?: (percent: number) => void | boolean) => Promise<string>;
static upscaleVideos: (sourceFolder: string, destFolder?: string, options?: Waifu2xVideoOptions, totalProgress?: (current: number, total: number) => void | boolean, progress?: (current: number, total: number) => void | boolean) => Promise<string[]>;
static pdfDimensions: (source: string, options?: Waifu2xPDFOptions) => Promise<{
width: number;
height: number;
image: string;
}>;
static dumpPDFFrames: (source: string, savePath: string, options?: Waifu2xPDFOptions) => Promise<string>;
static upscalePDF: (source: string, dest?: string, options?: Waifu2xPDFOptions, progress?: (current: number, total: number) => void | boolean) => Promise<string>;
static upscalePDFs: (sourceFolder: string, destFolder?: string, options?: Waifu2xPDFOptions, progress?: (current: number, total: number) => void | boolean) => Promise<string[]>;
private static removeDirectory;
}