From ffefbd2ecce8f530c743085476bbe32f980c3609 Mon Sep 17 00:00:00 2001 From: pilotso11 Date: Fri, 4 Aug 2023 10:51:06 +0100 Subject: [PATCH] TypeScript: add missing WebpPresetEnum (#3748) --- lib/index.d.ts | 11 +++++++++++ test/types/sharp.test-d.ts | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/index.d.ts b/lib/index.d.ts index 31b86fa8..25d75452 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -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 { @@ -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'; diff --git a/test/types/sharp.test-d.ts b/test/types/sharp.test-d.ts index f2aae985..5014e225 100644 --- a/test/types/sharp.test-d.ts +++ b/test/types/sharp.test-d.ts @@ -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'); +