Skip to content

Commit

Permalink
TypeScript: add missing WebpPresetEnum (#3748)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotso11 authored Aug 4, 2023
1 parent bc8f983 commit ffefbd2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,8 @@ declare namespace sharp {
minSize?: number;
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
mixed?: boolean;
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
preset?: keyof PresetEnum | undefined;
}

interface AvifOptions extends OutputOptions {
Expand Down Expand Up @@ -1476,6 +1478,15 @@ declare namespace sharp {
lanczos3: 'lanczos3';
}

interface PresetEnum {
default: 'default';
picture: 'picture';
photo: 'photo';
drawing: 'drawing';
icon: 'icon';
text: 'text';
}

interface BoolEnum {
and: 'and';
or: 'or';
Expand Down
10 changes: 10 additions & 0 deletions test/types/sharp.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,13 @@ sharp(input).composite([
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');

0 comments on commit ffefbd2

Please sign in to comment.