node-webp.ts
Version:
Convert image to webp and compress to save space with `cwebp` system program.
37 lines (36 loc) • 1.17 kB
TypeScript
export type CwebpOptions = {
input: string;
output: string;
/** quality: 0..100, default 75 */
quality?: number;
/** size: max bytes */
size?: number;
preset?: 'default' | 'photo' | 'picture' | 'drawing' | 'icon' | 'text';
hint?: 'photo' | 'picture' | 'graph';
low_memory?: boolean;
lossless?: boolean;
/** near_lossless: 0..100, typically 60 */
near_lossless?: number;
/** method: 0..6, default 4 */
method?: number;
auto_filter?: boolean;
/** deblocking_filter: 0..100, typically 20..50 */
deblocking_filter?: number;
/** spatial_noise_shaping: 0..100, default 50 */
spatial_noise_shaping?: number;
/** metadata: default 'none' */
metadata?: 'all' | 'none' | 'exif' | 'icc' | 'xmp';
/** crop is applied before resize */
crop?: {
top: number;
left: number;
width: number;
height: number;
};
resize?: {
width: number;
height: number;
};
};
export declare function cwebp(options: CwebpOptions, cb: (code: number | null) => void): void;
export declare function cwebp(options: CwebpOptions): Promise<number | null>;