TypeScript: add missing WebpPresetEnum (#3748)

This commit is contained in:
pilotso11 2023-08-04 10:51:06 +01:00 committed by GitHub
parent bc8f983329
commit ffefbd2ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

11
lib/index.d.ts vendored
View File

@ -1127,6 +1127,8 @@ declare namespace sharp {
minSize?: number; minSize?: number;
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */ /** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
mixed?: boolean; mixed?: boolean;
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
preset?: keyof PresetEnum | undefined;
} }
interface AvifOptions extends OutputOptions { interface AvifOptions extends OutputOptions {
@ -1476,6 +1478,15 @@ declare namespace sharp {
lanczos3: 'lanczos3'; lanczos3: 'lanczos3';
} }
interface PresetEnum {
default: 'default';
picture: 'picture';
photo: 'photo';
drawing: 'drawing';
icon: 'icon';
text: 'text';
}
interface BoolEnum { interface BoolEnum {
and: 'and'; and: 'and';
or: 'or'; or: 'or';

View File

@ -651,3 +651,13 @@ sharp(input).composite([
unlimited: true, unlimited: true,
} }
]); ]);
// Support for webp preset in types
// https://github.com/lovell/sharp/issues/3747
sharp('input.tiff').webp({ preset: 'photo' }).toFile('out.webp');
sharp('input.tiff').webp({ preset: 'picture' }).toFile('out.webp');
sharp('input.tiff').webp({ preset: 'icon' }).toFile('out.webp');
sharp('input.tiff').webp({ preset: 'drawing' }).toFile('out.webp');
sharp('input.tiff').webp({ preset: 'text' }).toFile('out.webp');
sharp('input.tiff').webp({ preset: 'default' }).toFile('out.webp');