sharp 0.33.5 → 0.34.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/channel.js CHANGED
@@ -16,7 +16,7 @@ const bool = {
16
16
  };
17
17
 
18
18
  /**
19
- * Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.
19
+ * Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.
20
20
  *
21
21
  * See also {@link /api-operation#flatten|flatten}.
22
22
  *
@@ -158,6 +158,7 @@ function bandbool (boolOp) {
158
158
 
159
159
  /**
160
160
  * Decorate the Sharp prototype with channel-related functions.
161
+ * @module Sharp
161
162
  * @private
162
163
  */
163
164
  module.exports = function (Sharp) {
package/lib/colour.js CHANGED
@@ -39,9 +39,9 @@ function tint (tint) {
39
39
  /**
40
40
  * Convert to 8-bit greyscale; 256 shades of grey.
41
41
  * This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.
42
- * By default the output image will be web-friendly sRGB and contain three (identical) color channels.
42
+ * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
43
43
  * This may be overridden by other sharp operations such as `toColourspace('b-w')`,
44
- * which will produce an output image containing one color channel.
44
+ * which will produce an output image containing one colour channel.
45
45
  * An alpha channel may be present, and will be unchanged by the operation.
46
46
  *
47
47
  * @example
@@ -159,6 +159,7 @@ function _setBackgroundColourOption (key, value) {
159
159
 
160
160
  /**
161
161
  * Decorate the Sharp prototype with colour-related functions.
162
+ * @module Sharp
162
163
  * @private
163
164
  */
164
165
  module.exports = function (Sharp) {
package/lib/composite.js CHANGED
@@ -46,8 +46,8 @@ const blend = {
46
46
  * The images to composite must be the same size or smaller than the processed image.
47
47
  * If both `top` and `left` options are provided, they take precedence over `gravity`.
48
48
  *
49
- * Any resize, rotate or extract operations in the same processing pipeline
50
- * will always be applied to the input image before composition.
49
+ * Other operations in the same processing pipeline (e.g. resize, rotate, flip,
50
+ * flop, extract) will always be applied to the input image before composition.
51
51
  *
52
52
  * The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,
53
53
  * `dest`, `dest-over`, `dest-in`, `dest-out`, `dest-atop`,
@@ -110,6 +110,7 @@ const blend = {
110
110
  * @param {number} [images[].input.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
111
111
  * @param {boolean} [images[].input.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for Pango markup features like `<span foreground="red">Red!</span>`.
112
112
  * @param {number} [images[].input.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
113
+ * @param {Boolean} [images[].autoOrient=false] - set to true to use EXIF orientation data, if present, to orient the image.
113
114
  * @param {String} [images[].blend='over'] - how to blend this image with the image below.
114
115
  * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay.
115
116
  * @param {Number} [images[].top] - the pixel offset from the top edge.
@@ -202,6 +203,7 @@ function composite (images) {
202
203
 
203
204
  /**
204
205
  * Decorate the Sharp prototype with composite-related functions.
206
+ * @module Sharp
205
207
  * @private
206
208
  */
207
209
  module.exports = function (Sharp) {
@@ -121,10 +121,25 @@ const debuglog = util.debuglog('sharp');
121
121
  * }
122
122
  * }).toFile('text_rgba.png');
123
123
  *
124
- * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string)} [input] - if present, can be
124
+ * @example
125
+ * // Join four input images as a 2x2 grid with a 4 pixel gutter
126
+ * const data = await sharp(
127
+ * [image1, image2, image3, image4],
128
+ * { join: { across: 2, shim: 4 } }
129
+ * ).toBuffer();
130
+ *
131
+ * @example
132
+ * // Generate a two-frame animated image from emoji
133
+ * const images = ['😀', '😛'].map(text => ({
134
+ * text: { text, width: 64, height: 64, channels: 4, rgba: true }
135
+ * }));
136
+ * await sharp(images, { join: { animated: true } }).toFile('out.gif');
137
+ *
138
+ * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string|Array)} [input] - if present, can be
125
139
  * a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or
126
140
  * a TypedArray containing raw pixel image data, or
127
141
  * a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.
142
+ * An array of inputs can be provided, and these will be joined together.
128
143
  * JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
129
144
  * @param {Object} [options] - if present, is an Object with optional attributes.
130
145
  * @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort.
@@ -132,6 +147,7 @@ const debuglog = util.debuglog('sharp');
132
147
  * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.
133
148
  * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
134
149
  * @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).
150
+ * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.
135
151
  * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
136
152
  * @param {number} [options.density=72] - number representing the DPI for vector images in the range 1 to 100000.
137
153
  * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
@@ -139,6 +155,7 @@ const debuglog = util.debuglog('sharp');
139
155
  * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
140
156
  * @param {number} [options.subifd=-1] - subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image.
141
157
  * @param {number} [options.level=0] - level to extract from a multi-level input (OpenSlide), zero based.
158
+ * @param {string|Object} [options.pdfBackground] - Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick.
142
159
  * @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.
143
160
  * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
144
161
  * @param {number} [options.raw.width] - integral number of pixels wide.
@@ -167,6 +184,14 @@ const debuglog = util.debuglog('sharp');
167
184
  * @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground="red">Red!</span>`.
168
185
  * @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
169
186
  * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.
187
+ * @param {Object} [options.join] - describes how an array of input images should be joined.
188
+ * @param {number} [options.join.across=1] - number of images to join horizontally.
189
+ * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.
190
+ * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.
191
+ * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
192
+ * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).
193
+ * @param {string} [options.join.valign='top'] - vertical alignment style for images joined vertically (`'top'`, `'centre'`, `'center'`, `'bottom'`).
194
+ *
170
195
  * @returns {Sharp}
171
196
  * @throws {Error} Invalid parameters
172
197
  */
@@ -193,7 +218,6 @@ const Sharp = function (input, options) {
193
218
  canvas: 'crop',
194
219
  position: 0,
195
220
  resizeBackground: [0, 0, 0, 255],
196
- useExifOrientation: false,
197
221
  angle: 0,
198
222
  rotationAngle: 0,
199
223
  rotationBackground: [0, 0, 0, 255],
@@ -299,6 +323,7 @@ const Sharp = function (input, options) {
299
323
  webpLossless: false,
300
324
  webpNearLossless: false,
301
325
  webpSmartSubsample: false,
326
+ webpSmartDeblock: false,
302
327
  webpPreset: 'default',
303
328
  webpEffort: 4,
304
329
  webpMinSize: false,
@@ -348,6 +373,7 @@ const Sharp = function (input, options) {
348
373
  timeoutSeconds: 0,
349
374
  linearA: [],
350
375
  linearB: [],
376
+ pdfBackground: [255, 255, 255, 255],
351
377
  // Function to notify of libvips warnings
352
378
  debuglog: warning => {
353
379
  this.emit('warning', warning);
@@ -447,6 +473,7 @@ Object.assign(Sharp.prototype, { clone });
447
473
 
448
474
  /**
449
475
  * Export constructor.
476
+ * @module Sharp
450
477
  * @private
451
478
  */
452
479
  module.exports = Sharp;
package/lib/index.d.ts CHANGED
@@ -40,19 +40,7 @@ import { Duplex } from 'stream';
40
40
  */
41
41
  declare function sharp(options?: sharp.SharpOptions): sharp.Sharp;
42
42
  declare 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,
43
+ input?: sharp.SharpInput | Array<sharp.SharpInput>,
56
44
  options?: sharp.SharpOptions,
57
45
  ): sharp.Sharp;
58
46
 
@@ -62,33 +50,35 @@ declare namespace sharp {
62
50
 
63
51
  /** An Object containing the version numbers of sharp, libvips and its dependencies. */
64
52
  const versions: {
65
- vips: string;
53
+ aom?: string | undefined;
54
+ archive?: string | undefined;
66
55
  cairo?: string | undefined;
67
- croco?: string | undefined;
56
+ cgif?: string | undefined;
68
57
  exif?: string | undefined;
69
58
  expat?: string | undefined;
70
59
  ffi?: string | undefined;
71
60
  fontconfig?: string | undefined;
72
61
  freetype?: string | undefined;
73
- gdkpixbuf?: string | undefined;
74
- gif?: string | undefined;
62
+ fribidi?: string | undefined;
75
63
  glib?: string | undefined;
76
- gsf?: string | undefined;
77
64
  harfbuzz?: string | undefined;
78
- jpeg?: string | undefined;
65
+ heif?: string | undefined;
66
+ highway?: string | undefined;
67
+ imagequant?: string | undefined;
79
68
  lcms?: string | undefined;
80
- orc?: string | undefined;
69
+ mozjpeg?: string | undefined;
81
70
  pango?: string | undefined;
82
71
  pixman?: string | undefined;
83
72
  png?: string | undefined;
84
- sharp?: string | undefined;
85
- svg?: string | undefined;
73
+ "proxy-libintl"?: string | undefined;
74
+ rsvg?: string | undefined;
75
+ sharp: string;
76
+ spng?: string | undefined;
86
77
  tiff?: string | undefined;
78
+ vips: string;
87
79
  webp?: string | undefined;
88
- avif?: string | undefined;
89
- heif?: string | undefined;
90
80
  xml?: string | undefined;
91
- zlib?: string | undefined;
81
+ "zlib-ng"?: string | undefined;
92
82
  };
93
83
 
94
84
  /** An Object containing the available interpolators and their proper values */
@@ -244,14 +234,14 @@ declare namespace sharp {
244
234
  * @param tint Parsed by the color module.
245
235
  * @returns A sharp instance that can be used to chain operations
246
236
  */
247
- tint(tint: Color): Sharp;
237
+ tint(tint: Colour | Color): Sharp;
248
238
 
249
239
  /**
250
240
  * Convert to 8-bit greyscale; 256 shades of grey.
251
241
  * This is a linear operation.
252
242
  * 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.
243
+ * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
244
+ * This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one colour channel.
255
245
  * An alpha channel may be present, and will be unchanged by the operation.
256
246
  * @param greyscale true to enable and false to disable (defaults to true)
257
247
  * @returns A sharp instance that can be used to chain operations
@@ -364,24 +354,72 @@ declare namespace sharp {
364
354
  //#region Operation functions
365
355
 
366
356
  /**
367
- * Rotate the output image by either an explicit angle or auto-orient based on the EXIF Orientation tag.
357
+ * Rotate the output image by either an explicit angle
358
+ * or auto-orient based on the EXIF `Orientation` tag.
368
359
  *
369
- * If an angle is provided, it is converted to a valid positive degree rotation. For example, -450 will produce a 270deg rotation.
360
+ * If an angle is provided, it is converted to a valid positive degree rotation.
361
+ * For example, `-450` will produce a 270 degree rotation.
370
362
  *
371
- * When rotating by an angle other than a multiple of 90, the background colour can be provided with the background option.
363
+ * When rotating by an angle other than a multiple of 90,
364
+ * the background colour can be provided with the `background` option.
372
365
  *
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.
366
+ * If no angle is provided, it is determined from the EXIF data.
367
+ * Mirroring is supported and may infer the use of a flip operation.
374
368
  *
375
- * The use of rotate implies the removal of the EXIF Orientation tag, if any.
369
+ * The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if any.
376
370
  *
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.
371
+ * Only one rotation can occur per pipeline (aside from an initial call without
372
+ * arguments to orient via EXIF data). Previous calls to `rotate` in the same
373
+ * pipeline will be ignored.
374
+ *
375
+ * Multi-page images can only be rotated by 180 degrees.
376
+ *
377
+ * Method order is important when rotating, resizing and/or extracting regions,
378
+ * for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
379
+ *
380
+ * @example
381
+ * const pipeline = sharp()
382
+ * .rotate()
383
+ * .resize(null, 200)
384
+ * .toBuffer(function (err, outputBuffer, info) {
385
+ * // outputBuffer contains 200px high JPEG image data,
386
+ * // auto-rotated using EXIF Orientation tag
387
+ * // info.width and info.height contain the dimensions of the resized image
388
+ * });
389
+ * readableStream.pipe(pipeline);
390
+ *
391
+ * @example
392
+ * const rotateThenResize = await sharp(input)
393
+ * .rotate(90)
394
+ * .resize({ width: 16, height: 8, fit: 'fill' })
395
+ * .toBuffer();
396
+ * const resizeThenRotate = await sharp(input)
397
+ * .resize({ width: 16, height: 8, fit: 'fill' })
398
+ * .rotate(90)
399
+ * .toBuffer();
400
+ *
401
+ * @param {number} [angle=auto] angle of rotation.
402
+ * @param {Object} [options] - if present, is an Object with optional attributes.
403
+ * @param {string|Object} [options.background="#000000"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
404
+ * @returns {Sharp}
380
405
  * @throws {Error} Invalid parameters
381
- * @returns A sharp instance that can be used to chain operations
382
406
  */
383
407
  rotate(angle?: number, options?: RotateOptions): Sharp;
384
408
 
409
+ /**
410
+ * Alias for calling `rotate()` with no arguments, which orients the image based
411
+ * on EXIF orientsion.
412
+ *
413
+ * This operation is aliased to emphasize its purpose, helping to remove any
414
+ * confusion between rotation and orientation.
415
+ *
416
+ * @example
417
+ * const output = await sharp(input).autoOrient().toBuffer();
418
+ *
419
+ * @returns {Sharp}
420
+ */
421
+ autoOrient(): Sharp
422
+
385
423
  /**
386
424
  * Flip the image about the vertical Y axis. This always occurs after rotation, if any.
387
425
  * The use of flip implies the removal of the EXIF Orientation tag, if any.
@@ -401,7 +439,7 @@ declare namespace sharp {
401
439
  /**
402
440
  * Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.
403
441
  * 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.
442
+ * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
405
443
  * 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
444
  *
407
445
  * In the case of a 2x2 matrix, the transform is:
@@ -799,8 +837,6 @@ declare namespace sharp {
799
837
  * Use tile-based deep zoom (image pyramid) output.
800
838
  * Set the format and options for tile images via the toFormat, jpeg, png or webp functions.
801
839
  * 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
840
  * @param tile tile options
805
841
  * @throws {Error} Invalid options
806
842
  * @returns A sharp instance that can be used to chain operations
@@ -899,7 +935,27 @@ declare namespace sharp {
899
935
  //#endregion
900
936
  }
901
937
 
938
+ type SharpInput = Buffer
939
+ | ArrayBuffer
940
+ | Uint8Array
941
+ | Uint8ClampedArray
942
+ | Int8Array
943
+ | Uint16Array
944
+ | Int16Array
945
+ | Uint32Array
946
+ | Int32Array
947
+ | Float32Array
948
+ | Float64Array
949
+ | string;
950
+
902
951
  interface SharpOptions {
952
+ /**
953
+ * Auto-orient based on the EXIF `Orientation` tag, if present.
954
+ * Mirroring is supported and may infer the use of a flip operation.
955
+ *
956
+ * Using this option will remove the EXIF `Orientation` tag, if any.
957
+ */
958
+ autoOrient?: boolean;
903
959
  /**
904
960
  * When to abort processing of invalid pixel data, one of (in order of sensitivity):
905
961
  * 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
@@ -935,6 +991,8 @@ declare namespace sharp {
935
991
  subifd?: number | undefined;
936
992
  /** Level to extract from a multi-level input (OpenSlide), zero based. (optional, default 0) */
937
993
  level?: number | undefined;
994
+ /** Background colour to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. */
995
+ pdfBackground?: Colour | Color | undefined;
938
996
  /** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
939
997
  animated?: boolean | undefined;
940
998
  /** Describes raw pixel input image data. See raw() for pixel ordering. */
@@ -943,6 +1001,8 @@ declare namespace sharp {
943
1001
  create?: Create | undefined;
944
1002
  /** Describes a new text image to be created. */
945
1003
  text?: CreateText | undefined;
1004
+ /** Describes how array of input images should be joined. */
1005
+ join?: Join | undefined;
946
1006
  }
947
1007
 
948
1008
  interface CacheOptions {
@@ -969,7 +1029,7 @@ declare namespace sharp {
969
1029
  interface Raw {
970
1030
  width: number;
971
1031
  height: number;
972
- channels: 1 | 2 | 3 | 4;
1032
+ channels: Channels;
973
1033
  }
974
1034
 
975
1035
  interface CreateRaw extends Raw {
@@ -977,15 +1037,17 @@ declare namespace sharp {
977
1037
  premultiplied?: boolean | undefined;
978
1038
  }
979
1039
 
1040
+ type CreateChannels = 3 | 4;
1041
+
980
1042
  interface Create {
981
1043
  /** Number of pixels wide. */
982
1044
  width: number;
983
1045
  /** Number of pixels high. */
984
1046
  height: number;
985
- /** Number of bands e.g. 3 for RGB, 4 for RGBA */
986
- channels: Channels;
1047
+ /** Number of bands, 3 for RGB, 4 for RGBA */
1048
+ channels: CreateChannels;
987
1049
  /** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
988
- background: Color;
1050
+ background: Colour | Color;
989
1051
  /** Describes a noise to be created. */
990
1052
  noise?: Noise | undefined;
991
1053
  }
@@ -1021,6 +1083,21 @@ declare namespace sharp {
1021
1083
  wrap?: TextWrap;
1022
1084
  }
1023
1085
 
1086
+ interface Join {
1087
+ /** Number of images per row. */
1088
+ across?: number | undefined;
1089
+ /** Treat input as frames of an animated image. */
1090
+ animated?: boolean | undefined;
1091
+ /** Space between images, in pixels. */
1092
+ shim?: number | undefined;
1093
+ /** Background colour. */
1094
+ background?: Colour | Color | undefined;
1095
+ /** Horizontal alignment. */
1096
+ halign?: HorizontalAlignment | undefined;
1097
+ /** Vertical alignment. */
1098
+ valign?: VerticalAlignment | undefined;
1099
+ }
1100
+
1024
1101
  interface ExifDir {
1025
1102
  [k: string]: string;
1026
1103
  }
@@ -1060,6 +1137,13 @@ declare namespace sharp {
1060
1137
  width?: number | undefined;
1061
1138
  /** Number of pixels high (EXIF orientation is not taken into consideration) */
1062
1139
  height?: number | undefined;
1140
+ /** Any changed metadata after the image orientation is applied. */
1141
+ autoOrient: {
1142
+ /** Number of pixels wide (EXIF orientation is taken into consideration) */
1143
+ width: number;
1144
+ /** Number of pixels high (EXIF orientation is taken into consideration) */
1145
+ height: number;
1146
+ };
1063
1147
  /** Name of colour space interpretation */
1064
1148
  space?: keyof ColourspaceEnum | undefined;
1065
1149
  /** Number of bands e.g. 3 for sRGB, 4 for CMYK */
@@ -1072,6 +1156,10 @@ declare namespace sharp {
1072
1156
  chromaSubsampling?: string | undefined;
1073
1157
  /** Boolean indicating whether the image is interlaced using a progressive scan */
1074
1158
  isProgressive?: boolean | undefined;
1159
+ /** Boolean indicating whether the image is palette-based (GIF, PNG). */
1160
+ isPalette?: boolean | undefined;
1161
+ /** Number of bits per sample for each channel (GIF, PNG). */
1162
+ bitsPerSample?: number | undefined;
1075
1163
  /** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
1076
1164
  pages?: number | undefined;
1077
1165
  /** Number of pixels high each page in a multi-page image will be. */
@@ -1098,8 +1186,8 @@ declare namespace sharp {
1098
1186
  tifftagPhotoshop?: Buffer | undefined;
1099
1187
  /** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
1100
1188
  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;
1189
+ /** Default background colour, if present, for PNG (bKGD) and GIF images */
1190
+ background?: { r: number; g: number; b: number } | { gray: number };
1103
1191
  /** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
1104
1192
  levels?: LevelMetadata[] | undefined;
1105
1193
  /** Number of Sub Image File Directories in an OME-TIFF image */
@@ -1339,7 +1427,7 @@ declare namespace sharp {
1339
1427
 
1340
1428
  interface RotateOptions {
1341
1429
  /** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
1342
- background?: Color | undefined;
1430
+ background?: Colour | Color | undefined;
1343
1431
  }
1344
1432
 
1345
1433
  type Precision = 'integer' | 'float' | 'approximate';
@@ -1355,7 +1443,7 @@ declare namespace sharp {
1355
1443
 
1356
1444
  interface FlattenOptions {
1357
1445
  /** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
1358
- background?: Color | undefined;
1446
+ background?: Colour | Color | undefined;
1359
1447
  }
1360
1448
 
1361
1449
  interface NegateOptions {
@@ -1380,7 +1468,7 @@ declare namespace sharp {
1380
1468
  /** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
1381
1469
  position?: number | string | undefined;
1382
1470
  /** 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}) */
1383
- background?: Color | undefined;
1471
+ background?: Colour | Color | undefined;
1384
1472
  /** The kernel to use for image reduction. (optional, default 'lanczos3') */
1385
1473
  kernel?: keyof KernelEnum | undefined;
1386
1474
  /** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
@@ -1423,14 +1511,14 @@ declare namespace sharp {
1423
1511
  /** single pixel count to right edge (optional, default 0) */
1424
1512
  right?: number | undefined;
1425
1513
  /** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
1426
- background?: Color | undefined;
1514
+ background?: Colour | Color | undefined;
1427
1515
  /** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
1428
1516
  extendWith?: ExtendWith | undefined;
1429
1517
  }
1430
1518
 
1431
1519
  interface TrimOptions {
1432
1520
  /** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
1433
- background?: Color | undefined;
1521
+ background?: Colour | Color | undefined;
1434
1522
  /** Allowed difference from the above colour, a positive number. (optional, default 10) */
1435
1523
  threshold?: number | undefined;
1436
1524
  /** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
@@ -1441,8 +1529,8 @@ declare namespace sharp {
1441
1529
  depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
1442
1530
  }
1443
1531
 
1444
- /** 3 for sRGB, 4 for CMYK */
1445
- type Channels = 3 | 4;
1532
+ /** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
1533
+ type Channels = 1 | 2 | 3 | 4;
1446
1534
 
1447
1535
  interface RGBA {
1448
1536
  r?: number | undefined;
@@ -1451,7 +1539,8 @@ declare namespace sharp {
1451
1539
  alpha?: number | undefined;
1452
1540
  }
1453
1541
 
1454
- type Color = string | RGBA;
1542
+ type Colour = string | RGBA;
1543
+ type Color = Colour;
1455
1544
 
1456
1545
  interface Kernel {
1457
1546
  /** width of the kernel in pixels. */
@@ -1505,6 +1594,8 @@ declare namespace sharp {
1505
1594
  failOn?: FailOnOptions | undefined;
1506
1595
  /** see sharp() constructor, (optional, default 268402689) */
1507
1596
  limitInputPixels?: number | boolean | undefined;
1597
+ /** see sharp() constructor, (optional, default false) */
1598
+ autoOrient?: boolean | undefined;
1508
1599
  }
1509
1600
 
1510
1601
  interface TileOptions {
@@ -1576,7 +1667,7 @@ declare namespace sharp {
1576
1667
  size: number;
1577
1668
  width: number;
1578
1669
  height: number;
1579
- channels: 1 | 2 | 3 | 4;
1670
+ channels: Channels;
1580
1671
  /** indicating if premultiplication was used */
1581
1672
  premultiplied: boolean;
1582
1673
  /** Only defined when using a crop strategy */
@@ -1645,6 +1736,10 @@ declare namespace sharp {
1645
1736
 
1646
1737
  type TextWrap = 'word' | 'char' | 'word-char' | 'none';
1647
1738
 
1739
+ type HorizontalAlignment = 'left' | 'centre' | 'center' | 'right';
1740
+
1741
+ type VerticalAlignment = 'top' | 'centre' | 'center' | 'bottom';
1742
+
1648
1743
  type TileContainer = 'fs' | 'zip';
1649
1744
 
1650
1745
  type TileLayout = 'dz' | 'iiif' | 'iiif3' | 'zoomify' | 'google';