UNPKG

81.7 kBTypeScriptView Raw
1/**
2 * Copyright 2017 François Nguyen and others.
3 *
4 * Billy Kwok <https://github.com/billykwok>
5 * Bradley Odell <https://github.com/BTOdell>
6 * Espen Hovlandsdal <https://github.com/rexxars>
7 * Floris de Bijl <https://github.com/Fdebijl>
8 * François Nguyen <https://github.com/phurytw>
9 * Jamie Woodbury <https://github.com/JamieWoodbury>
10 * Wooseop Kim <https://github.com/wooseopkim>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18 * the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
21 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26// SPDX-License-Identifier: MIT
27
28/// <reference types="node" />
29
30import { Duplex } from 'stream';
31
32//#region Constructor functions
33
34/**
35 * Creates a sharp instance from an image
36 * @param input Buffer containing JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data, or String containing the path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.
37 * @param options Object with optional attributes.
38 * @throws {Error} Invalid parameters
39 * @returns A sharp instance that can be used to chain operations
40 */
41declare function sharp(options?: sharp.SharpOptions): sharp.Sharp;
42declare function sharp(
43 input?:
44 | Buffer
45 | ArrayBuffer
46 | Uint8Array
47 | Uint8ClampedArray
48 | Int8Array
49 | Uint16Array
50 | Int16Array
51 | Uint32Array
52 | Int32Array
53 | Float32Array
54 | Float64Array
55 | string,
56 options?: sharp.SharpOptions,
57): sharp.Sharp;
58
59declare namespace sharp {
60 /** Object containing nested boolean values representing the available input and output formats/methods. */
61 const format: FormatEnum;
62
63 /** An Object containing the version numbers of sharp, libvips and its dependencies. */
64 const versions: {
65 vips: string;
66 cairo?: string | undefined;
67 croco?: string | undefined;
68 exif?: string | undefined;
69 expat?: string | undefined;
70 ffi?: string | undefined;
71 fontconfig?: string | undefined;
72 freetype?: string | undefined;
73 gdkpixbuf?: string | undefined;
74 gif?: string | undefined;
75 glib?: string | undefined;
76 gsf?: string | undefined;
77 harfbuzz?: string | undefined;
78 jpeg?: string | undefined;
79 lcms?: string | undefined;
80 orc?: string | undefined;
81 pango?: string | undefined;
82 pixman?: string | undefined;
83 png?: string | undefined;
84 sharp?: string | undefined;
85 svg?: string | undefined;
86 tiff?: string | undefined;
87 webp?: string | undefined;
88 avif?: string | undefined;
89 heif?: string | undefined;
90 xml?: string | undefined;
91 zlib?: string | undefined;
92 };
93
94 /** An Object containing the available interpolators and their proper values */
95 const interpolators: Interpolators;
96
97 /** An EventEmitter that emits a change event when a task is either queued, waiting for libuv to provide a worker thread, complete */
98 const queue: NodeJS.EventEmitter;
99
100 //#endregion
101
102 //#region Utility functions
103
104 /**
105 * Gets or, when options are provided, sets the limits of libvips' operation cache.
106 * Existing entries in the cache will be trimmed after any change in limits.
107 * This method always returns cache statistics, useful for determining how much working memory is required for a particular task.
108 * @param options Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default true)
109 * @returns The cache results.
110 */
111 function cache(options?: boolean | CacheOptions): CacheResult;
112
113 /**
114 * Gets or sets the number of threads libvips' should create to process each image.
115 * The default value is the number of CPU cores. A value of 0 will reset to this default.
116 * The maximum number of images that can be processed in parallel is limited by libuv's UV_THREADPOOL_SIZE environment variable.
117 * @param concurrency The new concurrency value.
118 * @returns The current concurrency value.
119 */
120 function concurrency(concurrency?: number): number;
121
122 /**
123 * Provides access to internal task counters.
124 * @returns Object containing task counters
125 */
126 function counters(): SharpCounters;
127
128 /**
129 * Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with highway support.
130 * Improves the performance of resize, blur and sharpen operations by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
131 * @param enable enable or disable use of SIMD vector unit instructions
132 * @returns true if usage of SIMD vector unit instructions is enabled
133 */
134 function simd(enable?: boolean): boolean;
135
136 /**
137 * Block libvips operations at runtime.
138 *
139 * This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,
140 * which when set will block all "untrusted" operations.
141 *
142 * @since 0.32.4
143 *
144 * @example <caption>Block all TIFF input.</caption>
145 * sharp.block({
146 * operation: ['VipsForeignLoadTiff']
147 * });
148 *
149 * @param {Object} options
150 * @param {Array<string>} options.operation - List of libvips low-level operation names to block.
151 */
152 function block(options: { operation: string[] }): void;
153
154 /**
155 * Unblock libvips operations at runtime.
156 *
157 * This is useful for defining a list of allowed operations.
158 *
159 * @since 0.32.4
160 *
161 * @example <caption>Block all input except WebP from the filesystem.</caption>
162 * sharp.block({
163 * operation: ['VipsForeignLoad']
164 * });
165 * sharp.unblock({
166 * operation: ['VipsForeignLoadWebpFile']
167 * });
168 *
169 * @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>
170 * sharp.block({
171 * operation: ['VipsForeignLoad']
172 * });
173 * sharp.unblock({
174 * operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']
175 * });
176 *
177 * @param {Object} options
178 * @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.
179 */
180 function unblock(options: { operation: string[] }): void;
181
182 //#endregion
183
184 const gravity: GravityEnum;
185 const strategy: StrategyEnum;
186 const kernel: KernelEnum;
187 const fit: FitEnum;
188 const bool: BoolEnum;
189
190 interface Sharp extends Duplex {
191 //#region Channel functions
192
193 /**
194 * Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.
195 * @returns A sharp instance that can be used to chain operations
196 */
197 removeAlpha(): Sharp;
198
199 /**
200 * Ensure alpha channel, if missing. The added alpha channel will be fully opaque. This is a no-op if the image already has an alpha channel.
201 * @param alpha transparency level (0=fully-transparent, 1=fully-opaque) (optional, default 1).
202 * @returns A sharp instance that can be used to chain operations
203 */
204 ensureAlpha(alpha?: number): Sharp;
205
206 /**
207 * Extract a single channel from a multi-channel image.
208 * @param channel zero-indexed channel/band number to extract, or red, green, blue or alpha.
209 * @throws {Error} Invalid channel
210 * @returns A sharp instance that can be used to chain operations
211 */
212 extractChannel(channel: 0 | 1 | 2 | 3 | 'red' | 'green' | 'blue' | 'alpha'): Sharp;
213
214 /**
215 * Join one or more channels to the image. The meaning of the added channels depends on the output colourspace, set with toColourspace().
216 * By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels. Channel ordering follows vips convention:
217 * - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.
218 * - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.
219 *
220 * Buffers may be any of the image formats supported by sharp.
221 * For raw pixel input, the options object should contain a raw attribute, which follows the format of the attribute of the same name in the sharp() constructor.
222 * @param images one or more images (file paths, Buffers).
223 * @param options image options, see sharp() constructor.
224 * @throws {Error} Invalid parameters
225 * @returns A sharp instance that can be used to chain operations
226 */
227 joinChannel(images: string | Buffer | ArrayLike<string | Buffer>, options?: SharpOptions): Sharp;
228
229 /**
230 * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.
231 * @param boolOp one of "and", "or" or "eor" to perform that bitwise operation, like the C logic operators &, | and ^ respectively.
232 * @throws {Error} Invalid parameters
233 * @returns A sharp instance that can be used to chain operations
234 */
235 bandbool(boolOp: keyof BoolEnum): Sharp;
236
237 //#endregion
238
239 //#region Color functions
240
241 /**
242 * Tint the image using the provided colour.
243 * An alpha channel may be present and will be unchanged by the operation.
244 * @param tint Parsed by the color module.
245 * @returns A sharp instance that can be used to chain operations
246 */
247 tint(tint: Color): Sharp;
248
249 /**
250 * Convert to 8-bit greyscale; 256 shades of grey.
251 * This is a linear operation.
252 * If the input image is in a non-linear colour space such as sRGB, use gamma() with greyscale() for the best results.
253 * By default the output image will be web-friendly sRGB and contain three (identical) color channels.
254 * This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one color channel.
255 * An alpha channel may be present, and will be unchanged by the operation.
256 * @param greyscale true to enable and false to disable (defaults to true)
257 * @returns A sharp instance that can be used to chain operations
258 */
259 greyscale(greyscale?: boolean): Sharp;
260
261 /**
262 * Alternative spelling of greyscale().
263 * @param grayscale true to enable and false to disable (defaults to true)
264 * @returns A sharp instance that can be used to chain operations
265 */
266 grayscale(grayscale?: boolean): Sharp;
267
268 /**
269 * Set the pipeline colourspace.
270 * The input image will be converted to the provided colourspace at the start of the pipeline.
271 * All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
272 * This feature is experimental and has not yet been fully-tested with all operations.
273 *
274 * @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
275 * @throws {Error} Invalid parameters
276 * @returns A sharp instance that can be used to chain operations
277 */
278 pipelineColourspace(colourspace?: string): Sharp;
279
280 /**
281 * Alternative spelling of pipelineColourspace
282 * @param colorspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
283 * @throws {Error} Invalid parameters
284 * @returns A sharp instance that can be used to chain operations
285 */
286 pipelineColorspace(colorspace?: string): Sharp;
287
288 /**
289 * Set the output colourspace.
290 * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
291 * @param colourspace output colourspace e.g. srgb, rgb, cmyk, lab, b-w ...
292 * @throws {Error} Invalid parameters
293 * @returns A sharp instance that can be used to chain operations
294 */
295 toColourspace(colourspace?: string): Sharp;
296
297 /**
298 * Alternative spelling of toColourspace().
299 * @param colorspace output colorspace e.g. srgb, rgb, cmyk, lab, b-w ...
300 * @throws {Error} Invalid parameters
301 * @returns A sharp instance that can be used to chain operations
302 */
303 toColorspace(colorspace: string): Sharp;
304
305 //#endregion
306
307 //#region Composite functions
308
309 /**
310 * Composite image(s) over the processed (resized, extracted etc.) image.
311 *
312 * The images to composite must be the same size or smaller than the processed image.
313 * If both `top` and `left` options are provided, they take precedence over `gravity`.
314 * @param images - Ordered list of images to composite
315 * @throws {Error} Invalid parameters
316 * @returns A sharp instance that can be used to chain operations
317 */
318 composite(images: OverlayOptions[]): Sharp;
319
320 //#endregion
321
322 //#region Input functions
323
324 /**
325 * Take a "snapshot" of the Sharp instance, returning a new instance.
326 * Cloned instances inherit the input of their parent instance.
327 * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.
328 * @returns A sharp instance that can be used to chain operations
329 */
330 clone(): Sharp;
331
332 /**
333 * Fast access to (uncached) image metadata without decoding any compressed image data.
334 * @returns A sharp instance that can be used to chain operations
335 */
336 metadata(callback: (err: Error, metadata: Metadata) => void): Sharp;
337
338 /**
339 * Fast access to (uncached) image metadata without decoding any compressed image data.
340 * @returns A promise that resolves with a metadata object
341 */
342 metadata(): Promise<Metadata>;
343
344 /**
345 * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.
346 * @returns A sharp instance that can be used to chain operations
347 */
348 keepMetadata(): Sharp;
349
350 /**
351 * Access to pixel-derived image statistics for every channel in the image.
352 * @returns A sharp instance that can be used to chain operations
353 */
354 stats(callback: (err: Error, stats: Stats) => void): Sharp;
355
356 /**
357 * Access to pixel-derived image statistics for every channel in the image.
358 * @returns A promise that resolves with a stats object
359 */
360 stats(): Promise<Stats>;
361
362 //#endregion
363
364 //#region Operation functions
365
366 /**
367 * Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.
368 *
369 * If an angle is provided, it is converted to a valid positive degree rotation. For example, -450 will produce a 270deg rotation.
370 *
371 * When rotating by an angle other than a multiple of 90, the background colour can be provided with the background option.
372 *
373 * If no angle is provided, it is determined from the EXIF data. Mirroring is supported and may infer the use of a flip operation.
374 *
375 * The use of rotate implies the removal of the EXIF Orientation tag, if any.
376 *
377 * Method order is important when both rotating and extracting regions, for example rotate(x).extract(y) will produce a different result to extract(y).rotate(x).
378 * @param angle angle of rotation. (optional, default auto)
379 * @param options if present, is an Object with optional attributes.
380 * @throws {Error} Invalid parameters
381 * @returns A sharp instance that can be used to chain operations
382 */
383 rotate(angle?: number, options?: RotateOptions): Sharp;
384
385 /**
386 * Flip the image about the vertical Y axis. This always occurs after rotation, if any.
387 * The use of flip implies the removal of the EXIF Orientation tag, if any.
388 * @param flip true to enable and false to disable (defaults to true)
389 * @returns A sharp instance that can be used to chain operations
390 */
391 flip(flip?: boolean): Sharp;
392
393 /**
394 * Flop the image about the horizontal X axis. This always occurs after rotation, if any.
395 * The use of flop implies the removal of the EXIF Orientation tag, if any.
396 * @param flop true to enable and false to disable (defaults to true)
397 * @returns A sharp instance that can be used to chain operations
398 */
399 flop(flop?: boolean): Sharp;
400
401 /**
402 * Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.
403 * You must provide an array of length 4 or a 2x2 affine transformation matrix.
404 * By default, new pixels are filled with a black background. You can provide a background color with the `background` option.
405 * A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
406 *
407 * In the case of a 2x2 matrix, the transform is:
408 * X = matrix[0, 0] * (x + idx) + matrix[0, 1] * (y + idy) + odx
409 * Y = matrix[1, 0] * (x + idx) + matrix[1, 1] * (y + idy) + ody
410 *
411 * where:
412 *
413 * x and y are the coordinates in input image.
414 * X and Y are the coordinates in output image.
415 * (0,0) is the upper left corner.
416 *
417 * @param matrix Affine transformation matrix, may either by a array of length four or a 2x2 matrix array
418 * @param options if present, is an Object with optional attributes.
419 *
420 * @returns A sharp instance that can be used to chain operations
421 */
422 affine(matrix: [number, number, number, number] | Matrix2x2, options?: AffineOptions): Sharp;
423
424 /**
425 * Sharpen the image.
426 * When used without parameters, performs a fast, mild sharpen of the output image.
427 * When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
428 * Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
429 * @param options if present, is an Object with optional attributes
430 * @throws {Error} Invalid parameters
431 * @returns A sharp instance that can be used to chain operations
432 */
433 sharpen(options?: SharpenOptions): Sharp;
434
435 /**
436 * Sharpen the image.
437 * When used without parameters, performs a fast, mild sharpen of the output image.
438 * When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
439 * Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
440 * @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
441 * @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
442 * @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
443 * @throws {Error} Invalid parameters
444 * @returns A sharp instance that can be used to chain operations
445 *
446 * @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
447 */
448 sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
449
450 /**
451 * Apply median filter. When used without parameters the default window is 3x3.
452 * @param size square mask size: size x size (optional, default 3)
453 * @throws {Error} Invalid parameters
454 * @returns A sharp instance that can be used to chain operations
455 */
456 median(size?: number): Sharp;
457
458 /**
459 * Blur the image.
460 * When used without parameters, performs a fast, mild blur of the output image.
461 * When a sigma is provided, performs a slower, more accurate Gaussian blur.
462 * When a boolean sigma is provided, ether blur mild or disable blur
463 * @param sigma a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
464 * @throws {Error} Invalid parameters
465 * @returns A sharp instance that can be used to chain operations
466 */
467 blur(sigma?: number | boolean): Sharp;
468
469 /**
470 * Merge alpha transparency channel, if any, with background.
471 * @param flatten true to enable and false to disable (defaults to true)
472 * @returns A sharp instance that can be used to chain operations
473 */
474 flatten(flatten?: boolean | FlattenOptions): Sharp;
475
476 /**
477 * Ensure the image has an alpha channel with all white pixel values made fully transparent.
478 * Existing alpha channel values for non-white pixels remain unchanged.
479 * @returns A sharp instance that can be used to chain operations
480 */
481 unflatten(): Sharp;
482
483 /**
484 * Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of 1/gamma then increasing the encoding (brighten) post-resize at a factor of gamma.
485 * This can improve the perceived brightness of a resized image in non-linear colour spaces.
486 * JPEG and WebP input images will not take advantage of the shrink-on-load performance optimisation when applying a gamma correction.
487 * Supply a second argument to use a different output gamma value, otherwise the first value is used in both cases.
488 * @param gamma value between 1.0 and 3.0. (optional, default 2.2)
489 * @param gammaOut value between 1.0 and 3.0. (optional, defaults to same as gamma)
490 * @throws {Error} Invalid parameters
491 * @returns A sharp instance that can be used to chain operations
492 */
493 gamma(gamma?: number, gammaOut?: number): Sharp;
494
495 /**
496 * Produce the "negative" of the image.
497 * @param negate true to enable and false to disable, or an object of options (defaults to true)
498 * @returns A sharp instance that can be used to chain operations
499 */
500 negate(negate?: boolean | NegateOptions): Sharp;
501
502 /**
503 * Enhance output image contrast by stretching its luminance to cover a full dynamic range.
504 *
505 * Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.
506 *
507 * Luminance values below the `lower` percentile will be underexposed by clipping to zero.
508 * Luminance values above the `upper` percentile will be overexposed by clipping to the max pixel value.
509 *
510 * @param normalise options
511 * @throws {Error} Invalid parameters
512 * @returns A sharp instance that can be used to chain operations
513 */
514 normalise(normalise?: NormaliseOptions): Sharp;
515
516 /**
517 * Alternative spelling of normalise.
518 * @param normalize options
519 * @throws {Error} Invalid parameters
520 * @returns A sharp instance that can be used to chain operations
521 */
522 normalize(normalize?: NormaliseOptions): Sharp;
523
524 /**
525 * Perform contrast limiting adaptive histogram equalization (CLAHE)
526 *
527 * This will, in general, enhance the clarity of the image by bringing out
528 * darker details. Please read more about CLAHE here:
529 * https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE
530 *
531 * @param options clahe options
532 */
533 clahe(options: ClaheOptions): Sharp;
534
535 /**
536 * Convolve the image with the specified kernel.
537 * @param kernel the specified kernel
538 * @throws {Error} Invalid parameters
539 * @returns A sharp instance that can be used to chain operations
540 */
541 convolve(kernel: Kernel): Sharp;
542
543 /**
544 * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
545 * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
546 * @param options threshold options
547 * @throws {Error} Invalid parameters
548 * @returns A sharp instance that can be used to chain operations
549 */
550 threshold(threshold?: number, options?: ThresholdOptions): Sharp;
551
552 /**
553 * Perform a bitwise boolean operation with operand image.
554 * This operation creates an output image where each pixel is the result of the selected bitwise boolean operation between the corresponding pixels of the input images.
555 * @param operand Buffer containing image data or String containing the path to an image file.
556 * @param operator one of "and", "or" or "eor" to perform that bitwise operation, like the C logic operators &, | and ^ respectively.
557 * @param options describes operand when using raw pixel data.
558 * @throws {Error} Invalid parameters
559 * @returns A sharp instance that can be used to chain operations
560 */
561 boolean(operand: string | Buffer, operator: keyof BoolEnum, options?: { raw: Raw }): Sharp;
562
563 /**
564 * Apply the linear formula a * input + b to the image (levels adjustment)
565 * @param a multiplier (optional, default 1.0)
566 * @param b offset (optional, default 0.0)
567 * @throws {Error} Invalid parameters
568 * @returns A sharp instance that can be used to chain operations
569 */
570 linear(a?: number | number[] | null, b?: number | number[]): Sharp;
571
572 /**
573 * Recomb the image with the specified matrix.
574 * @param inputMatrix 3x3 Recombination matrix
575 * @throws {Error} Invalid parameters
576 * @returns A sharp instance that can be used to chain operations
577 */
578 recomb(inputMatrix: Matrix3x3): Sharp;
579
580 /**
581 * Transforms the image using brightness, saturation, hue rotation and lightness.
582 * Brightness and lightness both operate on luminance, with the difference being that brightness is multiplicative whereas lightness is additive.
583 * @param options describes the modulation
584 * @returns A sharp instance that can be used to chain operations
585 */
586 modulate(options?: {
587 brightness?: number | undefined;
588 saturation?: number | undefined;
589 hue?: number | undefined;
590 lightness?: number | undefined;
591 }): Sharp;
592
593 //#endregion
594
595 //#region Output functions
596
597 /**
598 * Write output image data to a file.
599 * If an explicit output format is not selected, it will be inferred from the extension, with JPEG, PNG, WebP, AVIF, TIFF, DZI, and libvips' V format supported.
600 * Note that raw pixel data is only supported for buffer output.
601 * @param fileOut The path to write the image data to.
602 * @param callback Callback function called on completion with two arguments (err, info). info contains the output image format, size (bytes), width, height and channels.
603 * @throws {Error} Invalid parameters
604 * @returns A sharp instance that can be used to chain operations
605 */
606 toFile(fileOut: string, callback: (err: Error, info: OutputInfo) => void): Sharp;
607
608 /**
609 * Write output image data to a file.
610 * @param fileOut The path to write the image data to.
611 * @throws {Error} Invalid parameters
612 * @returns A promise that fulfills with an object containing information on the resulting file
613 */
614 toFile(fileOut: string): Promise<OutputInfo>;
615
616 /**
617 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
618 * By default, the format will match the input image, except SVG input which becomes PNG output.
619 * @param callback Callback function called on completion with three arguments (err, buffer, info).
620 * @returns A sharp instance that can be used to chain operations
621 */
622 toBuffer(callback: (err: Error, buffer: Buffer, info: OutputInfo) => void): Sharp;
623
624 /**
625 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
626 * By default, the format will match the input image, except SVG input which becomes PNG output.
627 * @param options resolve options
628 * @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
629 * @returns A promise that resolves with the Buffer data.
630 */
631 toBuffer(options?: { resolveWithObject: false }): Promise<Buffer>;
632
633 /**
634 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
635 * By default, the format will match the input image, except SVG input which becomes PNG output.
636 * @param options resolve options
637 * @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
638 * @returns A promise that resolves with an object containing the Buffer data and an info object containing the output image format, size (bytes), width, height and channels
639 */
640 toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer; info: OutputInfo }>;
641
642 /**
643 * Keep all EXIF metadata from the input image in the output image.
644 * EXIF metadata is unsupported for TIFF output.
645 * @returns A sharp instance that can be used to chain operations
646 */
647 keepExif(): Sharp;
648
649 /**
650 * Set EXIF metadata in the output image, ignoring any EXIF in the input image.
651 * @param {Exif} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.
652 * @returns A sharp instance that can be used to chain operations
653 * @throws {Error} Invalid parameters
654 */
655 withExif(exif: Exif): Sharp;
656
657 /**
658 * Update EXIF metadata from the input image in the output image.
659 * @param {Exif} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.
660 * @returns A sharp instance that can be used to chain operations
661 * @throws {Error} Invalid parameters
662 */
663 withExifMerge(exif: Exif): Sharp;
664
665 /**
666 * Keep ICC profile from the input image in the output image where possible.
667 * @returns A sharp instance that can be used to chain operations
668 */
669 keepIccProfile(): Sharp;
670
671 /**
672 * Transform using an ICC profile and attach to the output image.
673 * @param {string} icc - Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk).
674 * @returns A sharp instance that can be used to chain operations
675 * @throws {Error} Invalid parameters
676 */
677 withIccProfile(icc: string, options?: WithIccProfileOptions): Sharp;
678
679 /**
680 * Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
681 * The default behaviour, when withMetadata is not used, is to strip all metadata and convert to the device-independent sRGB colour space.
682 * This will also convert to and add a web-friendly sRGB ICC profile.
683 * @param withMetadata
684 * @throws {Error} Invalid parameters.
685 */
686 withMetadata(withMetadata?: WriteableMetadata): Sharp;
687
688 /**
689 * Use these JPEG options for output image.
690 * @param options Output options.
691 * @throws {Error} Invalid options
692 * @returns A sharp instance that can be used to chain operations
693 */
694 jpeg(options?: JpegOptions): Sharp;
695
696 /**
697 * Use these JP2 (JPEG 2000) options for output image.
698 * @param options Output options.
699 * @throws {Error} Invalid options
700 * @returns A sharp instance that can be used to chain operations
701 */
702 jp2(options?: Jp2Options): Sharp;
703
704 /**
705 * Use these JPEG-XL (JXL) options for output image.
706 * This feature is experimental, please do not use in production systems.
707 * Requires libvips compiled with support for libjxl.
708 * The prebuilt binaries do not include this.
709 * Image metadata (EXIF, XMP) is unsupported.
710 * @param options Output options.
711 * @throws {Error} Invalid options
712 * @returns A sharp instance that can be used to chain operations
713 */
714 jxl(options?: JxlOptions): Sharp;
715
716 /**
717 * Use these PNG options for output image.
718 * PNG output is always full colour at 8 or 16 bits per pixel.
719 * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
720 * @param options Output options.
721 * @throws {Error} Invalid options
722 * @returns A sharp instance that can be used to chain operations
723 */
724 png(options?: PngOptions): Sharp;
725
726 /**
727 * Use these WebP options for output image.
728 * @param options Output options.
729 * @throws {Error} Invalid options
730 * @returns A sharp instance that can be used to chain operations
731 */
732 webp(options?: WebpOptions): Sharp;
733
734 /**
735 * Use these GIF options for output image.
736 * Requires libvips compiled with support for ImageMagick or GraphicsMagick. The prebuilt binaries do not include this - see installing a custom libvips.
737 * @param options Output options.
738 * @throws {Error} Invalid options
739 * @returns A sharp instance that can be used to chain operations
740 */
741 gif(options?: GifOptions): Sharp;
742
743 /**
744 * Use these AVIF options for output image.
745 * @param options Output options.
746 * @throws {Error} Invalid options
747 * @returns A sharp instance that can be used to chain operations
748 */
749 avif(options?: AvifOptions): Sharp;
750
751 /**
752 * Use these HEIF options for output image.
753 * Support for patent-encumbered HEIC images requires the use of a globally-installed libvips compiled with support for libheif, libde265 and x265.
754 * @param options Output options.
755 * @throws {Error} Invalid options
756 * @returns A sharp instance that can be used to chain operations
757 */
758 heif(options?: HeifOptions): Sharp;
759
760 /**
761 * Use these TIFF options for output image.
762 * @param options Output options.
763 * @throws {Error} Invalid options
764 * @returns A sharp instance that can be used to chain operations
765 */
766 tiff(options?: TiffOptions): Sharp;
767
768 /**
769 * Force output to be raw, uncompressed uint8 pixel data.
770 * @param options Raw output options.
771 * @throws {Error} Invalid options
772 * @returns A sharp instance that can be used to chain operations
773 */
774 raw(options?: RawOptions): Sharp;
775
776 /**
777 * Force output to a given format.
778 * @param format a String or an Object with an 'id' attribute
779 * @param options output options
780 * @throws {Error} Unsupported format or options
781 * @returns A sharp instance that can be used to chain operations
782 */
783 toFormat(
784 format: keyof FormatEnum | AvailableFormatInfo,
785 options?:
786 | OutputOptions
787 | JpegOptions
788 | PngOptions
789 | WebpOptions
790 | AvifOptions
791 | HeifOptions
792 | JxlOptions
793 | GifOptions
794 | Jp2Options
795 | TiffOptions,
796 ): Sharp;
797
798 /**
799 * Use tile-based deep zoom (image pyramid) output.
800 * Set the format and options for tile images via the toFormat, jpeg, png or webp functions.
801 * Use a .zip or .szi file extension with toFile to write to a compressed archive file format.
802 *
803 * Warning: multiple sharp instances concurrently producing tile output can expose a possible race condition in some versions of libgsf.
804 * @param tile tile options
805 * @throws {Error} Invalid options
806 * @returns A sharp instance that can be used to chain operations
807 */
808 tile(tile?: TileOptions): Sharp;
809
810 /**
811 * Set a timeout for processing, in seconds. Use a value of zero to continue processing indefinitely, the default behaviour.
812 * The clock starts when libvips opens an input image for processing. Time spent waiting for a libuv thread to become available is not included.
813 * @param options Object with a `seconds` attribute between 0 and 3600 (number)
814 * @throws {Error} Invalid options
815 * @returns A sharp instance that can be used to chain operations
816 */
817 timeout(options: TimeoutOptions): Sharp;
818
819 //#endregion
820
821 //#region Resize functions
822
823 /**
824 * Resize image to width, height or width x height.
825 *
826 * When both a width and height are provided, the possible methods by which the image should fit these are:
827 * - cover: Crop to cover both provided dimensions (the default).
828 * - contain: Embed within both provided dimensions.
829 * - fill: Ignore the aspect ratio of the input and stretch to both provided dimensions.
830 * - inside: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
831 * - outside: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.
832 * Some of these values are based on the object-fit CSS property.
833 *
834 * When using a fit of cover or contain, the default position is centre. Other options are:
835 * - sharp.position: top, right top, right, right bottom, bottom, left bottom, left, left top.
836 * - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
837 * - sharp.strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.
838 *
839 * The experimental strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
840 * discarding the edge with the lowest score based on the selected strategy.
841 * - entropy: focus on the region with the highest Shannon entropy.
842 * - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
843 *
844 * Possible interpolation kernels are:
845 * - nearest: Use nearest neighbour interpolation.
846 * - cubic: Use a Catmull-Rom spline.
847 * - lanczos2: Use a Lanczos kernel with a=2.
848 * - lanczos3: Use a Lanczos kernel with a=3 (the default).
849 *
850 * @param width pixels wide the resultant image should be. Use null or undefined to auto-scale the width to match the height.
851 * @param height pixels high the resultant image should be. Use null or undefined to auto-scale the height to match the width.
852 * @param options resize options
853 * @throws {Error} Invalid parameters
854 * @returns A sharp instance that can be used to chain operations
855 */
856 resize(widthOrOptions?: number | ResizeOptions | null, height?: number | null, options?: ResizeOptions): Sharp;
857
858 /**
859 * Shorthand for resize(null, null, options);
860 *
861 * @param options resize options
862 * @throws {Error} Invalid parameters
863 * @returns A sharp instance that can be used to chain operations
864 */
865 resize(options: ResizeOptions): Sharp;
866
867 /**
868 * Extend / pad / extrude one or more edges of the image with either
869 * the provided background colour or pixels derived from the image.
870 * This operation will always occur after resizing and extraction, if any.
871 * @param extend single pixel count to add to all edges or an Object with per-edge counts
872 * @throws {Error} Invalid parameters
873 * @returns A sharp instance that can be used to chain operations
874 */
875 extend(extend: number | ExtendOptions): Sharp;
876
877 /**
878 * Extract a region of the image.
879 * - Use extract() before resize() for pre-resize extraction.
880 * - Use extract() after resize() for post-resize extraction.
881 * - Use extract() before and after for both.
882 *
883 * @param region The region to extract
884 * @throws {Error} Invalid parameters
885 * @returns A sharp instance that can be used to chain operations
886 */
887 extract(region: Region): Sharp;
888
889 /**
890 * Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel.
891 * Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels.
892 * The info response Object will contain trimOffsetLeft and trimOffsetTop properties.
893 * @param options trim options
894 * @throws {Error} Invalid parameters
895 * @returns A sharp instance that can be used to chain operations
896 */
897 trim(options?: TrimOptions): Sharp;
898
899 //#endregion
900 }
901
902 interface SharpOptions {
903 /**
904 * When to abort processing of invalid pixel data, one of (in order of sensitivity):
905 * 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
906 */
907 failOn?: FailOnOptions | undefined;
908 /**
909 * By default halt processing and raise an error when loading invalid images.
910 * Set this flag to false if you'd rather apply a "best effort" to decode images,
911 * even if the data is corrupt or invalid. (optional, default true)
912 *
913 * @deprecated Use `failOn` instead
914 */
915 failOnError?: boolean | undefined;
916 /**
917 * Do not process input images where the number of pixels (width x height) exceeds this limit.
918 * Assumes image dimensions contained in the input metadata can be trusted.
919 * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF). (optional, default 268402689)
920 */
921 limitInputPixels?: number | boolean | undefined;
922 /** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */
923 unlimited?: boolean | undefined;
924 /** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
925 sequentialRead?: boolean | undefined;
926 /** Number representing the DPI for vector images in the range 1 to 100000. (optional, default 72) */
927 density?: number | undefined;
928 /** Should the embedded ICC profile, if any, be ignored. */
929 ignoreIcc?: boolean | undefined;
930 /** Number of pages to extract for multi-page input (GIF, TIFF, PDF), use -1 for all pages */
931 pages?: number | undefined;
932 /** Page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based. (optional, default 0) */
933 page?: number | undefined;
934 /** subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image. (optional, default -1) */
935 subifd?: number | undefined;
936 /** Level to extract from a multi-level input (OpenSlide), zero based. (optional, default 0) */
937 level?: number | undefined;
938 /** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
939 animated?: boolean | undefined;
940 /** Describes raw pixel input image data. See raw() for pixel ordering. */
941 raw?: CreateRaw | undefined;
942 /** Describes a new image to be created. */
943 create?: Create | undefined;
944 /** Describes a new text image to be created. */
945 text?: CreateText | undefined;
946 }
947
948 interface CacheOptions {
949 /** Is the maximum memory in MB to use for this cache (optional, default 50) */
950 memory?: number | undefined;
951 /** Is the maximum number of files to hold open (optional, default 20) */
952 files?: number | undefined;
953 /** Is the maximum number of operations to cache (optional, default 100) */
954 items?: number | undefined;
955 }
956
957 interface TimeoutOptions {
958 /** Number of seconds after which processing will be stopped (default 0, eg disabled) */
959 seconds: number;
960 }
961
962 interface SharpCounters {
963 /** The number of tasks this module has queued waiting for libuv to provide a worker thread from its pool. */
964 queue: number;
965 /** The number of resize tasks currently being processed. */
966 process: number;
967 }
968
969 interface Raw {
970 width: number;
971 height: number;
972 channels: 1 | 2 | 3 | 4;
973 }
974
975 interface CreateRaw extends Raw {
976 /** Specifies that the raw input has already been premultiplied, set to true to avoid sharp premultiplying the image. (optional, default false) */
977 premultiplied?: boolean | undefined;
978 }
979
980 interface Create {
981 /** Number of pixels wide. */
982 width: number;
983 /** Number of pixels high. */
984 height: number;
985 /** Number of bands e.g. 3 for RGB, 4 for RGBA */
986 channels: Channels;
987 /** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
988 background: Color;
989 /** Describes a noise to be created. */
990 noise?: Noise | undefined;
991 }
992
993 interface CreateText {
994 /** Text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`. */
995 text: string;
996 /** Font name to render with. */
997 font?: string;
998 /** Absolute filesystem path to a font file that can be used by `font`. */
999 fontfile?: string;
1000 /** Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries. (optional, default `0`) */
1001 width?: number;
1002 /**
1003 * Integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution
1004 * defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0. (optional, default `0`)
1005 */
1006 height?: number;
1007 /** Text alignment ('left', 'centre', 'center', 'right'). (optional, default 'left') */
1008 align?: TextAlign;
1009 /** Set this to true to apply justification to the text. (optional, default `false`) */
1010 justify?: boolean;
1011 /** The resolution (size) at which to render the text. Does not take effect if `height` is specified. (optional, default `72`) */
1012 dpi?: number;
1013 /**
1014 * Set this to true to enable RGBA output. This is useful for colour emoji rendering,
1015 * or support for pango markup features like `<span foreground="red">Red!</span>`. (optional, default `false`)
1016 */
1017 rgba?: boolean;
1018 /** Text line height in points. Will use the font line height if none is specified. (optional, default `0`) */
1019 spacing?: number;
1020 /** Word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none' */
1021 wrap?: TextWrap;
1022 }
1023
1024 interface ExifDir {
1025 [k: string]: string;
1026 }
1027
1028 interface Exif {
1029 'IFD0'?: ExifDir;
1030 'IFD1'?: ExifDir;
1031 'IFD2'?: ExifDir;
1032 'IFD3'?: ExifDir;
1033 }
1034
1035 interface WriteableMetadata {
1036 /** Number of pixels per inch (DPI) */
1037 density?: number | undefined;
1038 /** Value between 1 and 8, used to update the EXIF Orientation tag. */
1039 orientation?: number | undefined;
1040 /**
1041 * Filesystem path to output ICC profile, defaults to sRGB.
1042 * @deprecated Use `withIccProfile()` instead.
1043 */
1044 icc?: string | undefined;
1045 /**
1046 * Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.
1047 * @deprecated Use `withExif()` or `withExifMerge()` instead.
1048 */
1049 exif?: Exif | undefined;
1050 }
1051
1052 interface Metadata {
1053 /** Number value of the EXIF Orientation header, if present */
1054 orientation?: number | undefined;
1055 /** Name of decoder used to decompress image data e.g. jpeg, png, webp, gif, svg */
1056 format?: keyof FormatEnum | undefined;
1057 /** Total size of image in bytes, for Stream and Buffer input only */
1058 size?: number | undefined;
1059 /** Number of pixels wide (EXIF orientation is not taken into consideration) */
1060 width?: number | undefined;
1061 /** Number of pixels high (EXIF orientation is not taken into consideration) */
1062 height?: number | undefined;
1063 /** Name of colour space interpretation */
1064 space?: keyof ColourspaceEnum | undefined;
1065 /** Number of bands e.g. 3 for sRGB, 4 for CMYK */
1066 channels?: Channels | undefined;
1067 /** Name of pixel depth format e.g. uchar, char, ushort, float ... */
1068 depth?: string | undefined;
1069 /** Number of pixels per inch (DPI), if present */
1070 density?: number | undefined;
1071 /** String containing JPEG chroma subsampling, 4:2:0 or 4:4:4 for RGB, 4:2:0:4 or 4:4:4:4 for CMYK */
1072 chromaSubsampling: string;
1073 /** Boolean indicating whether the image is interlaced using a progressive scan */
1074 isProgressive?: boolean | undefined;
1075 /** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
1076 pages?: number | undefined;
1077 /** Number of pixels high each page in a multi-page image will be. */
1078 pageHeight?: number | undefined;
1079 /** Number of times to loop an animated image, zero refers to a continuous loop. */
1080 loop?: number | undefined;
1081 /** Delay in ms between each page in an animated image, provided as an array of integers. */
1082 delay?: number[] | undefined;
1083 /** Number of the primary page in a HEIF image */
1084 pagePrimary?: number | undefined;
1085 /** Boolean indicating the presence of an embedded ICC profile */
1086 hasProfile?: boolean | undefined;
1087 /** Boolean indicating the presence of an alpha transparency channel */
1088 hasAlpha?: boolean | undefined;
1089 /** Buffer containing raw EXIF data, if present */
1090 exif?: Buffer | undefined;
1091 /** Buffer containing raw ICC profile data, if present */
1092 icc?: Buffer | undefined;
1093 /** Buffer containing raw IPTC data, if present */
1094 iptc?: Buffer | undefined;
1095 /** Buffer containing raw XMP data, if present */
1096 xmp?: Buffer | undefined;
1097 /** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
1098 tifftagPhotoshop?: Buffer | undefined;
1099 /** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
1100 compression?: 'av1' | 'hevc';
1101 /** Default background colour, if present, for PNG (bKGD) and GIF images, either an RGB Object or a single greyscale value */
1102 background?: { r: number; g: number; b: number } | number;
1103 /** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
1104 levels?: LevelMetadata[] | undefined;
1105 /** Number of Sub Image File Directories in an OME-TIFF image */
1106 subifds?: number | undefined;
1107 /** The unit of resolution (density) */
1108 resolutionUnit?: 'inch' | 'cm' | undefined;
1109 /** String containing format for images loaded via *magick */
1110 formatMagick?: string | undefined;
1111 }
1112
1113 interface LevelMetadata {
1114 width: number;
1115 height: number;
1116 }
1117
1118 interface Stats {
1119 /** Array of channel statistics for each channel in the image. */
1120 channels: ChannelStats[];
1121 /** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
1122 isOpaque: boolean;
1123 /** Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental) */
1124 entropy: number;
1125 /** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental) */
1126 sharpness: number;
1127 /** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram (experimental) */
1128 dominant: { r: number; g: number; b: number };
1129 }
1130
1131 interface ChannelStats {
1132 /** minimum value in the channel */
1133 min: number;
1134 /** maximum value in the channel */
1135 max: number;
1136 /** sum of all values in a channel */
1137 sum: number;
1138 /** sum of squared values in a channel */
1139 squaresSum: number;
1140 /** mean of the values in a channel */
1141 mean: number;
1142 /** standard deviation for the values in a channel */
1143 stdev: number;
1144 /** x-coordinate of one of the pixel where the minimum lies */
1145 minX: number;
1146 /** y-coordinate of one of the pixel where the minimum lies */
1147 minY: number;
1148 /** x-coordinate of one of the pixel where the maximum lies */
1149 maxX: number;
1150 /** y-coordinate of one of the pixel where the maximum lies */
1151 maxY: number;
1152 }
1153
1154 interface OutputOptions {
1155 /** Force format output, otherwise attempt to use input format (optional, default true) */
1156 force?: boolean | undefined;
1157 }
1158
1159 interface WithIccProfileOptions {
1160 /** Should the ICC profile be included in the output image metadata? (optional, default true) */
1161 attach?: boolean | undefined;
1162 }
1163
1164 interface JpegOptions extends OutputOptions {
1165 /** Quality, integer 1-100 (optional, default 80) */
1166 quality?: number | undefined;
1167 /** Use progressive (interlace) scan (optional, default false) */
1168 progressive?: boolean | undefined;
1169 /** Set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default '4:2:0') */
1170 chromaSubsampling?: string | undefined;
1171 /** Apply trellis quantisation (optional, default false) */
1172 trellisQuantisation?: boolean | undefined;
1173 /** Apply overshoot deringing (optional, default false) */
1174 overshootDeringing?: boolean | undefined;
1175 /** Optimise progressive scans, forces progressive (optional, default false) */
1176 optimiseScans?: boolean | undefined;
1177 /** Alternative spelling of optimiseScans (optional, default false) */
1178 optimizeScans?: boolean | undefined;
1179 /** Optimise Huffman coding tables (optional, default true) */
1180 optimiseCoding?: boolean | undefined;
1181 /** Alternative spelling of optimiseCoding (optional, default true) */
1182 optimizeCoding?: boolean | undefined;
1183 /** Quantization table to use, integer 0-8 (optional, default 0) */
1184 quantisationTable?: number | undefined;
1185 /** Alternative spelling of quantisationTable (optional, default 0) */
1186 quantizationTable?: number | undefined;
1187 /** Use mozjpeg defaults (optional, default false) */
1188 mozjpeg?: boolean | undefined;
1189 }
1190
1191 interface Jp2Options extends OutputOptions {
1192 /** Quality, integer 1-100 (optional, default 80) */
1193 quality?: number;
1194 /** Use lossless compression mode (optional, default false) */
1195 lossless?: boolean;
1196 /** Horizontal tile size (optional, default 512) */
1197 tileWidth?: number;
1198 /** Vertical tile size (optional, default 512) */
1199 tileHeight?: number;
1200 /** Set to '4:2:0' to enable chroma subsampling (optional, default '4:4:4') */
1201 chromaSubsampling?: '4:4:4' | '4:2:0';
1202 }
1203
1204 interface JxlOptions extends OutputOptions {
1205 /** Maximum encoding error, between 0 (highest quality) and 15 (lowest quality) (optional, default 1.0) */
1206 distance?: number;
1207 /** Calculate distance based on JPEG-like quality, between 1 and 100, overrides distance if specified */
1208 quality?: number;
1209 /** Target decode speed tier, between 0 (highest quality) and 4 (lowest quality) (optional, default 0) */
1210 decodingTier?: number;
1211 /** Use lossless compression (optional, default false) */
1212 lossless?: boolean;
1213 /** CPU effort, between 3 (fastest) and 9 (slowest) (optional, default 7) */
1214 effort?: number | undefined;
1215 }
1216
1217 interface WebpOptions extends OutputOptions, AnimationOptions {
1218 /** Quality, integer 1-100 (optional, default 80) */
1219 quality?: number | undefined;
1220 /** Quality of alpha layer, number from 0-100 (optional, default 100) */
1221 alphaQuality?: number | undefined;
1222 /** Use lossless compression mode (optional, default false) */
1223 lossless?: boolean | undefined;
1224 /** Use near_lossless compression mode (optional, default false) */
1225 nearLossless?: boolean | undefined;
1226 /** Use high quality chroma subsampling (optional, default false) */
1227 smartSubsample?: boolean | undefined;
1228 /** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
1229 effort?: number | undefined;
1230 /** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
1231 minSize?: boolean;
1232 /** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
1233 mixed?: boolean;
1234 /** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
1235 preset?: keyof PresetEnum | undefined;
1236 }
1237
1238 interface AvifOptions extends OutputOptions {
1239 /** quality, integer 1-100 (optional, default 50) */
1240 quality?: number | undefined;
1241 /** use lossless compression (optional, default false) */
1242 lossless?: boolean | undefined;
1243 /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
1244 effort?: number | undefined;
1245 /** set to '4:2:0' to use chroma subsampling, requires libvips v8.11.0 (optional, default '4:4:4') */
1246 chromaSubsampling?: string | undefined;
1247 /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1248 bitdepth?: 8 | 10 | 12 | undefined;
1249 }
1250
1251 interface HeifOptions extends OutputOptions {
1252 /** quality, integer 1-100 (optional, default 50) */
1253 quality?: number | undefined;
1254 /** compression format: av1, hevc (optional, default 'av1') */
1255 compression?: 'av1' | 'hevc' | undefined;
1256 /** use lossless compression (optional, default false) */
1257 lossless?: boolean | undefined;
1258 /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
1259 effort?: number | undefined;
1260 /** set to '4:2:0' to use chroma subsampling (optional, default '4:4:4') */
1261 chromaSubsampling?: string | undefined;
1262 /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1263 bitdepth?: 8 | 10 | 12 | undefined;
1264 }
1265
1266 interface GifOptions extends OutputOptions, AnimationOptions {
1267 /** Re-use existing palette, otherwise generate new (slow) */
1268 reuse?: boolean | undefined;
1269 /** Use progressive (interlace) scan */
1270 progressive?: boolean | undefined;
1271 /** Maximum number of palette entries, including transparency, between 2 and 256 (optional, default 256) */
1272 colours?: number | undefined;
1273 /** Alternative spelling of "colours". Maximum number of palette entries, including transparency, between 2 and 256 (optional, default 256) */
1274 colors?: number | undefined;
1275 /** Level of CPU effort to reduce file size, between 1 (fastest) and 10 (slowest) (optional, default 7) */
1276 effort?: number | undefined;
1277 /** Level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most) (optional, default 1.0) */
1278 dither?: number | undefined;
1279 /** Maximum inter-frame error for transparency, between 0 (lossless) and 32 (optional, default 0) */
1280 interFrameMaxError?: number;
1281 /** Maximum inter-palette error for palette reuse, between 0 and 256 (optional, default 3) */
1282 interPaletteMaxError?: number;
1283 }
1284
1285 interface TiffOptions extends OutputOptions {
1286 /** Quality, integer 1-100 (optional, default 80) */
1287 quality?: number | undefined;
1288 /** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
1289 compression?: string | undefined;
1290 /** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
1291 predictor?: string | undefined;
1292 /** Write an image pyramid (optional, default false) */
1293 pyramid?: boolean | undefined;
1294 /** Write a tiled tiff (optional, default false) */
1295 tile?: boolean | undefined;
1296 /** Horizontal tile size (optional, default 256) */
1297 tileWidth?: number | undefined;
1298 /** Vertical tile size (optional, default 256) */
1299 tileHeight?: number | undefined;
1300 /** Horizontal resolution in pixels/mm (optional, default 1.0) */
1301 xres?: number | undefined;
1302 /** Vertical resolution in pixels/mm (optional, default 1.0) */
1303 yres?: number | undefined;
1304 /** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
1305 bitdepth?: 1 | 2 | 4 | 8 | undefined;
1306 /** Write 1-bit images as miniswhite (optional, default false) */
1307 miniswhite?: boolean | undefined;
1308 /** Resolution unit options: inch, cm (optional, default 'inch') */
1309 resolutionUnit?: 'inch' | 'cm' | undefined;
1310 }
1311
1312 interface PngOptions extends OutputOptions {
1313 /** Use progressive (interlace) scan (optional, default false) */
1314 progressive?: boolean | undefined;
1315 /** zlib compression level, 0-9 (optional, default 6) */
1316 compressionLevel?: number | undefined;
1317 /** Use adaptive row filtering (optional, default false) */
1318 adaptiveFiltering?: boolean | undefined;
1319 /** Use the lowest number of colours needed to achieve given quality (optional, default `100`) */
1320 quality?: number | undefined;
1321 /** Level of CPU effort to reduce file size, between 1 (fastest) and 10 (slowest), sets palette to true (optional, default 7) */
1322 effort?: number | undefined;
1323 /** Quantise to a palette-based image with alpha transparency support (optional, default false) */
1324 palette?: boolean | undefined;
1325 /** Maximum number of palette entries (optional, default 256) */
1326 colours?: number | undefined;
1327 /** Alternative Spelling of "colours". Maximum number of palette entries (optional, default 256) */
1328 colors?: number | undefined;
1329 /** Level of Floyd-Steinberg error diffusion (optional, default 1.0) */
1330 dither?: number | undefined;
1331 }
1332
1333 interface RotateOptions {
1334 /** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
1335 background?: Color | undefined;
1336 }
1337
1338 interface FlattenOptions {
1339 /** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
1340 background?: Color | undefined;
1341 }
1342
1343 interface NegateOptions {
1344 /** whether or not to negate any alpha channel. (optional, default true) */
1345 alpha?: boolean | undefined;
1346 }
1347
1348 interface NormaliseOptions {
1349 /** Percentile below which luminance values will be underexposed. */
1350 lower?: number | undefined;
1351 /** Percentile above which luminance values will be overexposed. */
1352 upper?: number | undefined;
1353 }
1354
1355 interface ResizeOptions {
1356 /** Alternative means of specifying width. If both are present this takes priority. */
1357 width?: number | undefined;
1358 /** Alternative means of specifying height. If both are present this takes priority. */
1359 height?: number | undefined;
1360 /** How the image should be resized to fit both provided dimensions, one of cover, contain, fill, inside or outside. (optional, default 'cover') */
1361 fit?: keyof FitEnum | undefined;
1362 /** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
1363 position?: number | string | undefined;
1364 /** Background colour when using a fit of contain, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
1365 background?: Color | undefined;
1366 /** The kernel to use for image reduction. (optional, default 'lanczos3') */
1367 kernel?: keyof KernelEnum | undefined;
1368 /** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
1369 withoutEnlargement?: boolean | undefined;
1370 /** Do not reduce if the width or height are already greater than the specified dimensions, equivalent to GraphicsMagick's < geometry option. (optional, default false) */
1371 withoutReduction?: boolean | undefined;
1372 /** Take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moiré pattern on some images. (optional, default true) */
1373 fastShrinkOnLoad?: boolean | undefined;
1374 }
1375
1376 interface Region {
1377 /** zero-indexed offset from left edge */
1378 left: number;
1379 /** zero-indexed offset from top edge */
1380 top: number;
1381 /** dimension of extracted image */
1382 width: number;
1383 /** dimension of extracted image */
1384 height: number;
1385 }
1386
1387 interface Noise {
1388 /** type of generated noise, currently only gaussian is supported. */
1389 type?: 'gaussian' | undefined;
1390 /** mean of pixels in generated noise. */
1391 mean?: number | undefined;
1392 /** standard deviation of pixels in generated noise. */
1393 sigma?: number | undefined;
1394 }
1395
1396 type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
1397
1398 interface ExtendOptions {
1399 /** single pixel count to top edge (optional, default 0) */
1400 top?: number | undefined;
1401 /** single pixel count to left edge (optional, default 0) */
1402 left?: number | undefined;
1403 /** single pixel count to bottom edge (optional, default 0) */
1404 bottom?: number | undefined;
1405 /** single pixel count to right edge (optional, default 0) */
1406 right?: number | undefined;
1407 /** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
1408 background?: Color | undefined;
1409 /** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
1410 extendWith?: ExtendWith | undefined;
1411 }
1412
1413 interface TrimOptions {
1414 /** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
1415 background?: Color | undefined;
1416 /** Allowed difference from the above colour, a positive number. (optional, default 10) */
1417 threshold?: number | undefined;
1418 /** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
1419 lineArt?: boolean | undefined;
1420 }
1421
1422 interface RawOptions {
1423 depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
1424 }
1425
1426 /** 3 for sRGB, 4 for CMYK */
1427 type Channels = 3 | 4;
1428
1429 interface RGBA {
1430 r?: number | undefined;
1431 g?: number | undefined;
1432 b?: number | undefined;
1433 alpha?: number | undefined;
1434 }
1435
1436 type Color = string | RGBA;
1437
1438 interface Kernel {
1439 /** width of the kernel in pixels. */
1440 width: number;
1441 /** height of the kernel in pixels. */
1442 height: number;
1443 /** Array of length width*height containing the kernel values. */
1444 kernel: ArrayLike<number>;
1445 /** the scale of the kernel in pixels. (optional, default sum) */
1446 scale?: number | undefined;
1447 /** the offset of the kernel in pixels. (optional, default 0) */
1448 offset?: number | undefined;
1449 }
1450
1451 interface ClaheOptions {
1452 /** width of the region */
1453 width: number;
1454 /** height of the region */
1455 height: number;
1456 /** max slope of the cumulative contrast. A value of 0 disables contrast limiting. Valid values are integers in the range 0-100 (inclusive) (optional, default 3) */
1457 maxSlope?: number | undefined;
1458 }
1459
1460 interface ThresholdOptions {
1461 /** convert to single channel greyscale. (optional, default true) */
1462 greyscale?: boolean | undefined;
1463 /** alternative spelling for greyscale. (optional, default true) */
1464 grayscale?: boolean | undefined;
1465 }
1466
1467 interface OverlayOptions extends SharpOptions {
1468 /** Buffer containing image data, String containing the path to an image file, or Create object */
1469 input?: string | Buffer | { create: Create } | { text: CreateText } | { raw: CreateRaw } | undefined;
1470 /** how to blend this image with the image below. (optional, default `'over'`) */
1471 blend?: Blend | undefined;
1472 /** gravity at which to place the overlay. (optional, default 'centre') */
1473 gravity?: Gravity | undefined;
1474 /** the pixel offset from the top edge. */
1475 top?: number | undefined;
1476 /** the pixel offset from the left edge. */
1477 left?: number | undefined;
1478 /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1479 tile?: boolean | undefined;
1480 /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1481 premultiplied?: boolean | undefined;
1482 /** number representing the DPI for vector overlay image. (optional, default 72)*/
1483 density?: number | undefined;
1484 /** Set to true to read all frames/pages of an animated image. (optional, default false) */
1485 animated?: boolean | undefined;
1486 /** see sharp() constructor, (optional, default 'warning') */
1487 failOn?: FailOnOptions | undefined;
1488 /** see sharp() constructor, (optional, default 268402689) */
1489 limitInputPixels?: number | boolean | undefined;
1490 }
1491
1492 interface TileOptions {
1493 /** Tile size in pixels, a value between 1 and 8192. (optional, default 256) */
1494 size?: number | undefined;
1495 /** Tile overlap in pixels, a value between 0 and 8192. (optional, default 0) */
1496 overlap?: number | undefined;
1497 /** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
1498 angle?: number | undefined;
1499 /** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
1500 background?: string | RGBA | undefined;
1501 /** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
1502 depth?: string | undefined;
1503 /** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
1504 skipBlanks?: number | undefined;
1505 /** Tile container, with value fs (filesystem) or zip (compressed file). (optional, default 'fs') */
1506 container?: TileContainer | undefined;
1507 /** Filesystem layout, possible values are dz, iiif, iiif3, zoomify or google. (optional, default 'dz') */
1508 layout?: TileLayout | undefined;
1509 /** Centre image in tile. (optional, default false) */
1510 centre?: boolean | undefined;
1511 /** Alternative spelling of centre. (optional, default false) */
1512 center?: boolean | undefined;
1513 /** When layout is iiif/iiif3, sets the @id/id attribute of info.json (optional, default 'https://example.com/iiif') */
1514 id?: string | undefined;
1515 /** The name of the directory within the zip file when container is `zip`. */
1516 basename?: string | undefined;
1517 }
1518
1519 interface AnimationOptions {
1520 /** Number of animation iterations, a value between 0 and 65535. Use 0 for infinite animation. (optional, default 0) */
1521 loop?: number | undefined;
1522 /** delay(s) between animation frames (in milliseconds), each value between 0 and 65535. (optional) */
1523 delay?: number | number[] | undefined;
1524 }
1525
1526 interface SharpenOptions {
1527 /** The sigma of the Gaussian mask, where sigma = 1 + radius / 2, between 0.000001 and 10000 */
1528 sigma: number;
1529 /** The level of sharpening to apply to "flat" areas, between 0 and 1000000 (optional, default 1.0) */
1530 m1?: number | undefined;
1531 /** The level of sharpening to apply to "jagged" areas, between 0 and 1000000 (optional, default 2.0) */
1532 m2?: number | undefined;
1533 /** Threshold between "flat" and "jagged", between 0 and 1000000 (optional, default 2.0) */
1534 x1?: number | undefined;
1535 /** Maximum amount of brightening, between 0 and 1000000 (optional, default 10.0) */
1536 y2?: number | undefined;
1537 /** Maximum amount of darkening, between 0 and 1000000 (optional, default 20.0) */
1538 y3?: number | undefined;
1539 }
1540
1541 interface AffineOptions {
1542 /** Parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
1543 background?: string | object | undefined;
1544 /** Input horizontal offset (optional, default 0) */
1545 idx?: number | undefined;
1546 /** Input vertical offset (optional, default 0) */
1547 idy?: number | undefined;
1548 /** Output horizontal offset (optional, default 0) */
1549 odx?: number | undefined;
1550 /** Output horizontal offset (optional, default 0) */
1551 ody?: number | undefined;
1552 /** Interpolator (optional, default sharp.interpolators.bicubic) */
1553 interpolator?: Interpolators[keyof Interpolators] | undefined;
1554 }
1555
1556 interface OutputInfo {
1557 format: string;
1558 size: number;
1559 width: number;
1560 height: number;
1561 channels: 1 | 2 | 3 | 4;
1562 /** indicating if premultiplication was used */
1563 premultiplied: boolean;
1564 /** Only defined when using a crop strategy */
1565 cropOffsetLeft?: number | undefined;
1566 /** Only defined when using a crop strategy */
1567 cropOffsetTop?: number | undefined;
1568 /** Only defined when using a trim method */
1569 trimOffsetLeft?: number | undefined;
1570 /** Only defined when using a trim method */
1571 trimOffsetTop?: number | undefined;
1572 /** DPI the font was rendered at, only defined when using `text` input */
1573 textAutofitDpi?: number | undefined;
1574 /** When using the attention crop strategy, the focal point of the cropped region */
1575 attentionX?: number | undefined;
1576 attentionY?: number | undefined;
1577 }
1578
1579 interface AvailableFormatInfo {
1580 id: string;
1581 input: { file: boolean; buffer: boolean; stream: boolean; fileSuffix?: string[] };
1582 output: { file: boolean; buffer: boolean; stream: boolean; alias?: string[] };
1583 }
1584
1585 interface FitEnum {
1586 contain: 'contain';
1587 cover: 'cover';
1588 fill: 'fill';
1589 inside: 'inside';
1590 outside: 'outside';
1591 }
1592
1593 interface KernelEnum {
1594 nearest: 'nearest';
1595 cubic: 'cubic';
1596 mitchell: 'mitchell';
1597 lanczos2: 'lanczos2';
1598 lanczos3: 'lanczos3';
1599 }
1600
1601 interface PresetEnum {
1602 default: 'default';
1603 picture: 'picture';
1604 photo: 'photo';
1605 drawing: 'drawing';
1606 icon: 'icon';
1607 text: 'text';
1608 }
1609
1610 interface BoolEnum {
1611 and: 'and';
1612 or: 'or';
1613 eor: 'eor';
1614 }
1615
1616 interface ColourspaceEnum {
1617 multiband: string;
1618 'b-w': string;
1619 bw: string;
1620 cmyk: string;
1621 srgb: string;
1622 }
1623
1624 type FailOnOptions = 'none' | 'truncated' | 'error' | 'warning';
1625
1626 type TextAlign = 'left' | 'centre' | 'center' | 'right';
1627
1628 type TextWrap = 'word' | 'char' | 'word-char' | 'none';
1629
1630 type TileContainer = 'fs' | 'zip';
1631
1632 type TileLayout = 'dz' | 'iiif' | 'iiif3' | 'zoomify' | 'google';
1633
1634 type Blend =
1635 | 'clear'
1636 | 'source'
1637 | 'over'
1638 | 'in'
1639 | 'out'
1640 | 'atop'
1641 | 'dest'
1642 | 'dest-over'
1643 | 'dest-in'
1644 | 'dest-out'
1645 | 'dest-atop'
1646 | 'xor'
1647 | 'add'
1648 | 'saturate'
1649 | 'multiply'
1650 | 'screen'
1651 | 'overlay'
1652 | 'darken'
1653 | 'lighten'
1654 | 'color-dodge'
1655 | 'colour-dodge'
1656 | 'color-burn'
1657 | 'colour-burn'
1658 | 'hard-light'
1659 | 'soft-light'
1660 | 'difference'
1661 | 'exclusion';
1662
1663 type Gravity = number | string;
1664
1665 interface GravityEnum {
1666 north: number;
1667 northeast: number;
1668 southeast: number;
1669 south: number;
1670 southwest: number;
1671 west: number;
1672 northwest: number;
1673 east: number;
1674 center: number;
1675 centre: number;
1676 }
1677
1678 interface StrategyEnum {
1679 entropy: number;
1680 attention: number;
1681 }
1682
1683 interface FormatEnum {
1684 avif: AvailableFormatInfo;
1685 dz: AvailableFormatInfo;
1686 fits: AvailableFormatInfo;
1687 gif: AvailableFormatInfo;
1688 heif: AvailableFormatInfo;
1689 input: AvailableFormatInfo;
1690 jpeg: AvailableFormatInfo;
1691 jpg: AvailableFormatInfo;
1692 jp2: AvailableFormatInfo;
1693 jxl: AvailableFormatInfo;
1694 magick: AvailableFormatInfo;
1695 openslide: AvailableFormatInfo;
1696 pdf: AvailableFormatInfo;
1697 png: AvailableFormatInfo;
1698 ppm: AvailableFormatInfo;
1699 raw: AvailableFormatInfo;
1700 svg: AvailableFormatInfo;
1701 tiff: AvailableFormatInfo;
1702 tif: AvailableFormatInfo;
1703 v: AvailableFormatInfo;
1704 webp: AvailableFormatInfo;
1705 }
1706
1707 interface CacheResult {
1708 memory: { current: number; high: number; max: number };
1709 files: { current: number; max: number };
1710 items: { current: number; max: number };
1711 }
1712
1713 interface Interpolators {
1714 /** [Nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation). Suitable for image enlargement only. */
1715 nearest: 'nearest';
1716 /** [Bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation). Faster than bicubic but with less smooth results. */
1717 bilinear: 'bilinear';
1718 /** [Bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) (the default). */
1719 bicubic: 'bicubic';
1720 /**
1721 * [LBB interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/lbb.cpp#L100).
1722 * Prevents some "[acutance](http://en.wikipedia.org/wiki/Acutance)" but typically reduces performance by a factor of 2.
1723 */
1724 locallyBoundedBicubic: 'lbb';
1725 /** [Nohalo interpolation](http://eprints.soton.ac.uk/268086/). Prevents acutance but typically reduces performance by a factor of 3. */
1726 nohalo: 'nohalo';
1727 /** [VSQBS interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/vsqbs.cpp#L48). Prevents "staircasing" when enlarging. */
1728 vertexSplitQuadraticBasisSpline: 'vsqbs';
1729 }
1730
1731 type Matrix2x2 = [[number, number], [number, number]];
1732 type Matrix3x3 = [[number, number, number], [number, number, number], [number, number, number]];
1733}
1734
1735export = sharp;