From a5dce4de6a3bc8f7bc6556bf3484c6ddd5d1e9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Baumeyer?= Date: Thu, 21 Mar 2019 14:29:22 +0100 Subject: [PATCH] Update sharp types for 0.22.0 --- types/sharp/index.d.ts | 27 +++++++++++++++++++++++---- types/sharp/sharp-tests.ts | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/types/sharp/index.d.ts b/types/sharp/index.d.ts index 5fcc47a26d..a8d51f4257 100644 --- a/types/sharp/index.d.ts +++ b/types/sharp/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sharp 0.21 +// Type definitions for sharp 0.22 // Project: https://github.com/lovell/sharp // Definitions by: François Nguyen // Wooseop Kim @@ -138,7 +138,7 @@ declare namespace sharp { * @throws {Error} Invalid parameters * @returns A sharp instance that can be used to chain operations */ - joinChannel(images: string | Buffer | ArrayLike, options?: SharpOptions): Sharp; + joinChannel(images: string | Buffer | ArrayLike, options?: SharpOptions): Sharp; /** * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image. @@ -211,9 +211,21 @@ declare namespace sharp { * @param options overlay options * @throws {Error} Invalid parameters * @returns A sharp instance that can be used to chain operations + * @deprecated */ overlayWith(image?: string | Buffer, options?: OverlayOptions): Sharp; + /** + * Composite image(s) over the processed (resized, extracted etc.) image. + * + * The images to composite must be the same size or smaller than the processed image. + * If both `top` and `left` options are provided, they take precedence over `gravity`. + * @param images - Ordered list of images to composite + * @throws {Error} Invalid parameters + * @returns A sharp instance that can be used to chain operations + */ + composite(images: Array<{ input: string | Buffer } & OverlayOptions>): Sharp; + //#endregion //#region Input functions @@ -570,7 +582,7 @@ declare namespace sharp { * @throws {Error} Invalid parameters * @returns A sharp instance that can be used to chain operations */ - resize(width?: number|null, height?: number|null, options?: ResizeOptions): Sharp; + resize(width?: number | null, height?: number | null, options?: ResizeOptions): Sharp; /** * Extends/pads the edges of the image with the provided background colour. @@ -615,7 +627,9 @@ declare namespace sharp { failOnError?: boolean; /** Number representing the DPI for vector images. (optional, default 72) */ density?: number; - /** Page number to extract for multi-page input (GIF, TIFF). (optional, default 0) */ + /** Number of pages to extract for multi-page input (GIF, TIFF, PDF), use -1 for all pages */ + pages?: number; + /** Page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based. (optional, default 0) */ page?: number; /** Describes raw pixel input image data. See raw() for pixel ordering. */ raw?: Raw; @@ -883,6 +897,8 @@ declare namespace sharp { } interface OverlayOptions { + /** how to blend this image with the image below. (optional, default `'over'`) */ + blend?: Blend; /** gravity at which to place the overlay. (optional, default 'centre') */ gravity?: Gravity; /** the pixel offset from the top edge. */ @@ -966,6 +982,9 @@ declare namespace sharp { srgb: string; } + type Blend = 'clear' | 'source' | 'over' | 'in' | 'out' | 'atop' | 'dest' | 'dest-over' | 'dest-in' | 'dest-out' | 'dest-atop' | 'xor' | 'add' | 'saturate' | 'multiply' | 'screen' | 'overlay' + | 'darken' | 'lighten' | 'colour-dodge' | 'colour-dodge' | 'colour-burn' | 'colour-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion'; + type Gravity = number | string; interface GravityEnum { diff --git a/types/sharp/sharp-tests.ts b/types/sharp/sharp-tests.ts index 8c02e8c98f..84e1d33f4b 100644 --- a/types/sharp/sharp-tests.ts +++ b/types/sharp/sharp-tests.ts @@ -26,7 +26,7 @@ sharp('input.png') .rotate(180) .resize(300) .flatten({ background: "#ff6600" }) - .overlayWith('overlay.png', { gravity: sharp.gravity.southeast }) + .composite([{ input: 'overlay.png', gravity: sharp.gravity.southeast }]) .sharpen() .withMetadata() .webp({