@revizly/sharp 0.34.5-revizly3 → 0.35.0-revizly10

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/README.md CHANGED
@@ -8,7 +8,7 @@ smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions
8
8
 
9
9
  It can be used with all JavaScript runtimes
10
10
  that provide support for Node-API v9, including
11
- Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
11
+ Node.js (>= 20.9.0), Deno and Bun.
12
12
 
13
13
  Resizing an image is typically 4x-5x faster than using the
14
14
  quickest ImageMagick and GraphicsMagick settings
package/install/build.js CHANGED
@@ -10,7 +10,7 @@ const {
10
10
  spawnRebuild,
11
11
  } = require('../lib/libvips');
12
12
 
13
- log('Attempting to build from source via node-gyp');
13
+ log('Building from source');
14
14
  log('See https://sharp.pixelplumbing.com/install#building-from-source');
15
15
 
16
16
  try {
@@ -29,7 +29,7 @@ try {
29
29
  }
30
30
 
31
31
  if (useGlobalLibvips(log)) {
32
- log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
32
+ log(`Found globally-installed libvips v${globalLibvipsVersion()}`);
33
33
  }
34
34
 
35
35
  const status = spawnRebuild();
package/lib/channel.js CHANGED
@@ -18,7 +18,7 @@ const bool = {
18
18
  /**
19
19
  * Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.
20
20
  *
21
- * See also {@link /api-operation#flatten|flatten}.
21
+ * See also {@link /api-operation/#flatten flatten}.
22
22
  *
23
23
  * @example
24
24
  * sharp('rgba.png')
@@ -163,7 +163,7 @@ function bandbool (boolOp) {
163
163
  * @module Sharp
164
164
  * @private
165
165
  */
166
- module.exports = function (Sharp) {
166
+ module.exports = (Sharp) => {
167
167
  Object.assign(Sharp.prototype, {
168
168
  // Public instance functions
169
169
  removeAlpha,
package/lib/colour.js CHANGED
@@ -69,7 +69,7 @@ function grayscale (grayscale) {
69
69
  *
70
70
  * The input image will be converted to the provided colourspace at the start of the pipeline.
71
71
  * All operations will use this colourspace before converting to the output colourspace,
72
- * as defined by {@link #tocolourspace|toColourspace}.
72
+ * as defined by {@link #tocolourspace toColourspace}.
73
73
  *
74
74
  * @since 0.29.0
75
75
  *
@@ -80,7 +80,7 @@ function grayscale (grayscale) {
80
80
  * .toColourspace('srgb')
81
81
  * .toFile('16bpc-pipeline-to-8bpc-output.png')
82
82
  *
83
- * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://github.com/libvips/libvips/blob/41cff4e9d0838498487a00623462204eb10ee5b8/libvips/iofuncs/enumtypes.c#L774)
83
+ * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
84
84
  * @returns {Sharp}
85
85
  * @throws {Error} Invalid parameters
86
86
  */
@@ -112,7 +112,7 @@ function pipelineColorspace (colorspace) {
112
112
  * .toColourspace('rgb16')
113
113
  * .toFile('16-bpp.png')
114
114
  *
115
- * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/3c0bfdf74ce1dc37a6429bed47fa76f16e2cd70a/libvips/iofuncs/enumtypes.c#L777-L794)
115
+ * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
116
116
  * @returns {Sharp}
117
117
  * @throws {Error} Invalid parameters
118
118
  */
@@ -175,7 +175,7 @@ function _setBackgroundColourOption (key, value) {
175
175
  * @module Sharp
176
176
  * @private
177
177
  */
178
- module.exports = function (Sharp) {
178
+ module.exports = (Sharp) => {
179
179
  Object.assign(Sharp.prototype, {
180
180
  // Public
181
181
  tint,
package/lib/composite.js CHANGED
@@ -56,7 +56,7 @@ const blend = {
56
56
  * `hard-light`, `soft-light`, `difference`, `exclusion`.
57
57
  *
58
58
  * More information about blend modes can be found at
59
- * https://www.libvips.org/API/current/libvips-conversion.html#VipsBlendMode
59
+ * https://www.libvips.org/API/current/enum.BlendMode.html
60
60
  * and https://www.cairographics.org/operators/
61
61
  *
62
62
  * @since 0.22.0
@@ -123,8 +123,8 @@ const blend = {
123
123
  * @param {Number} [images[].raw.height]
124
124
  * @param {Number} [images[].raw.channels]
125
125
  * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.
126
- * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor#parameters|constructor parameters}
127
- * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor#parameters|constructor parameters}
126
+ * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor/ constructor parameters}
127
+ * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}
128
128
  * @returns {Sharp}
129
129
  * @throws {Error} Invalid parameters
130
130
  */
@@ -206,7 +206,7 @@ function composite (images) {
206
206
  * @module Sharp
207
207
  * @private
208
208
  */
209
- module.exports = function (Sharp) {
209
+ module.exports = (Sharp) => {
210
210
  Sharp.prototype.composite = composite;
211
211
  Sharp.blend = blend;
212
212
  };
@@ -12,6 +12,10 @@ require('./sharp');
12
12
  // Use NODE_DEBUG=sharp to enable libvips warnings
13
13
  const debuglog = util.debuglog('sharp');
14
14
 
15
+ const queueListener = (queueLength) => {
16
+ Sharp.queue.emit('change', queueLength);
17
+ };
18
+
15
19
  /**
16
20
  * Constructor factory to create an instance of `sharp`, to which further methods are chained.
17
21
  *
@@ -274,6 +278,7 @@ const Sharp = function (input, options) {
274
278
  trimBackground: [],
275
279
  trimThreshold: -1,
276
280
  trimLineArt: false,
281
+ trimMargin: 0,
277
282
  dilateWidth: 0,
278
283
  erodeWidth: 0,
279
284
  gamma: 0,
@@ -302,6 +307,7 @@ const Sharp = function (input, options) {
302
307
  fileOut: '',
303
308
  formatOut: 'input',
304
309
  streamOut: false,
310
+ typedArrayOut: false,
305
311
  keepMetadata: 0,
306
312
  withMetadataOrientation: -1,
307
313
  withMetadataDensity: 0,
@@ -309,6 +315,7 @@ const Sharp = function (input, options) {
309
315
  withExif: {},
310
316
  withExifMerge: true,
311
317
  withXmp: '',
318
+ withGainMap: false,
312
319
  resolveWithObject: false,
313
320
  loop: -1,
314
321
  delay: [],
@@ -344,6 +351,7 @@ const Sharp = function (input, options) {
344
351
  webpEffort: 4,
345
352
  webpMinSize: false,
346
353
  webpMixed: false,
354
+ webpExact: false,
347
355
  gifBitdepth: 8,
348
356
  gifEffort: 7,
349
357
  gifDither: 1,
@@ -358,7 +366,7 @@ const Sharp = function (input, options) {
358
366
  tiffPredictor: 'horizontal',
359
367
  tiffPyramid: false,
360
368
  tiffMiniswhite: false,
361
- tiffBitdepth: 8,
369
+ tiffBitdepth: 0,
362
370
  tiffTile: false,
363
371
  tiffTileHeight: 256,
364
372
  tiffTileWidth: 256,
@@ -371,6 +379,7 @@ const Sharp = function (input, options) {
371
379
  heifEffort: 4,
372
380
  heifChromaSubsampling: '4:4:4',
373
381
  heifBitdepth: 8,
382
+ heifTune: 'ssim',
374
383
  jxlDistance: 1,
375
384
  jxlDecodingTier: 0,
376
385
  jxlEffort: 7,
@@ -398,9 +407,7 @@ const Sharp = function (input, options) {
398
407
  debuglog(warning);
399
408
  },
400
409
  // Function to notify of queue length changes
401
- queueListener: function (queueLength) {
402
- Sharp.queue.emit('change', queueLength);
403
- }
410
+ queueListener
404
411
  };
405
412
  this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
406
413
  return this;
package/lib/index.d.ts CHANGED
@@ -259,7 +259,6 @@ declare namespace sharp {
259
259
  * Set the pipeline colourspace.
260
260
  * The input image will be converted to the provided colourspace at the start of the pipeline.
261
261
  * All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
262
- * This feature is experimental and has not yet been fully-tested with all operations.
263
262
  *
264
263
  * @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
265
264
  * @throws {Error} Invalid parameters
@@ -470,21 +469,6 @@ declare namespace sharp {
470
469
  */
471
470
  sharpen(options?: SharpenOptions): Sharp;
472
471
 
473
- /**
474
- * Sharpen the image.
475
- * When used without parameters, performs a fast, mild sharpen of the output image.
476
- * When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
477
- * Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
478
- * @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
479
- * @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
480
- * @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
481
- * @throws {Error} Invalid parameters
482
- * @returns A sharp instance that can be used to chain operations
483
- *
484
- * @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
485
- */
486
- sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
487
-
488
472
  /**
489
473
  * Apply median filter. When used without parameters the default window is 3x3.
490
474
  * @param size square mask size: size x size (optional, default 3)
@@ -693,6 +677,13 @@ declare namespace sharp {
693
677
  */
694
678
  toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer; info: OutputInfo }>;
695
679
 
680
+ /**
681
+ * Write output to a Uint8Array backed by a transferable ArrayBuffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
682
+ * By default, the format will match the input image, except SVG input which becomes PNG output.
683
+ * @returns A promise that resolves with an object containing the Uint8Array data and an info object containing the output image format, size (bytes), width, height and channels
684
+ */
685
+ toUint8Array(): Promise<{ data: Uint8Array; info: OutputInfo }>;
686
+
696
687
  /**
697
688
  * Keep all EXIF metadata from the input image in the output image.
698
689
  * EXIF metadata is unsupported for TIFF output.
@@ -849,7 +840,7 @@ declare namespace sharp {
849
840
  * @returns A sharp instance that can be used to chain operations
850
841
  */
851
842
  toFormat(
852
- format: keyof FormatEnum | AvailableFormatInfo,
843
+ format: keyof FormatEnum | AvailableFormatInfo | "avif",
853
844
  options?:
854
845
  | OutputOptions
855
846
  | JpegOptions
@@ -860,6 +851,7 @@ declare namespace sharp {
860
851
  | JxlOptions
861
852
  | GifOptions
862
853
  | Jp2Options
854
+ | RawOptions
863
855
  | TiffOptions,
864
856
  ): Sharp;
865
857
 
@@ -902,7 +894,7 @@ declare namespace sharp {
902
894
  * - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
903
895
  * - 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.
904
896
  *
905
- * The experimental strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
897
+ * The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
906
898
  * discarding the edge with the lowest score based on the selected strategy.
907
899
  * - entropy: focus on the region with the highest Shannon entropy.
908
900
  * - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
@@ -991,14 +983,6 @@ declare namespace sharp {
991
983
  * 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
992
984
  */
993
985
  failOn?: FailOnOptions | undefined;
994
- /**
995
- * By default halt processing and raise an error when loading invalid images.
996
- * Set this flag to false if you'd rather apply a "best effort" to decode images,
997
- * even if the data is corrupt or invalid. (optional, default true)
998
- *
999
- * @deprecated Use `failOn` instead
1000
- */
1001
- failOnError?: boolean | undefined;
1002
986
  /**
1003
987
  * Do not process input images where the number of pixels (width x height) exceeds this limit.
1004
988
  * Assumes image dimensions contained in the input metadata can be trusted.
@@ -1027,11 +1011,11 @@ declare namespace sharp {
1027
1011
  openSlide?: OpenSlideInputOptions | undefined;
1028
1012
  /** JPEG 2000 specific input options */
1029
1013
  jp2?: Jp2InputOptions | undefined;
1030
- /** Deprecated: use tiff.subifd instead */
1014
+ /** @deprecated Use {@link SharpOptions.tiff} instead */
1031
1015
  subifd?: number | undefined;
1032
- /** Deprecated: use pdf.background instead */
1016
+ /** @deprecated Use {@link SharpOptions.pdf} instead */
1033
1017
  pdfBackground?: Colour | Color | undefined;
1034
- /** Deprecated: use openSlide.level instead */
1018
+ /** @deprecated Use {@link SharpOptions.openSlide} instead */
1035
1019
  level?: number | undefined;
1036
1020
  /** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
1037
1021
  animated?: boolean | undefined;
@@ -1181,6 +1165,12 @@ declare namespace sharp {
1181
1165
  'IFD3'?: ExifDir;
1182
1166
  }
1183
1167
 
1168
+ type HeifCompression = 'av1' | 'hevc';
1169
+
1170
+ type HeifTune = 'iq' | 'ssim' | 'psnr';
1171
+
1172
+ type Unit = 'inch' | 'cm';
1173
+
1184
1174
  interface WriteableMetadata {
1185
1175
  /** Number of pixels per inch (DPI) */
1186
1176
  density?: number | undefined;
@@ -1259,7 +1249,7 @@ declare namespace sharp {
1259
1249
  /** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
1260
1250
  tifftagPhotoshop?: Buffer | undefined;
1261
1251
  /** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
1262
- compression?: 'av1' | 'hevc';
1252
+ compression?: HeifCompression | undefined;
1263
1253
  /** Default background colour, if present, for PNG (bKGD) and GIF images */
1264
1254
  background?: { r: number; g: number; b: number } | { gray: number };
1265
1255
  /** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
@@ -1267,11 +1257,13 @@ declare namespace sharp {
1267
1257
  /** Number of Sub Image File Directories in an OME-TIFF image */
1268
1258
  subifds?: number | undefined;
1269
1259
  /** The unit of resolution (density) */
1270
- resolutionUnit?: 'inch' | 'cm' | undefined;
1260
+ resolutionUnit?: Unit | undefined;
1271
1261
  /** String containing format for images loaded via *magick */
1272
1262
  formatMagick?: string | undefined;
1273
1263
  /** Array of keyword/text pairs representing PNG text blocks, if present. */
1274
1264
  comments?: CommentsMetadata[] | undefined;
1265
+ /** HDR gain map, if present */
1266
+ gainMap?: GainMapMetadata | undefined;
1275
1267
  }
1276
1268
 
1277
1269
  interface LevelMetadata {
@@ -1284,16 +1276,21 @@ declare namespace sharp {
1284
1276
  text: string;
1285
1277
  }
1286
1278
 
1279
+ interface GainMapMetadata {
1280
+ /** JPEG image */
1281
+ image: Buffer;
1282
+ }
1283
+
1287
1284
  interface Stats {
1288
1285
  /** Array of channel statistics for each channel in the image. */
1289
1286
  channels: ChannelStats[];
1290
1287
  /** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
1291
1288
  isOpaque: boolean;
1292
- /** Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental) */
1289
+ /** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
1293
1290
  entropy: number;
1294
- /** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental) */
1291
+ /** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
1295
1292
  sharpness: number;
1296
- /** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram (experimental) */
1293
+ /** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
1297
1294
  dominant: { r: number; g: number; b: number };
1298
1295
  }
1299
1296
 
@@ -1399,11 +1396,13 @@ declare namespace sharp {
1399
1396
  /** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
1400
1397
  effort?: number | undefined;
1401
1398
  /** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
1402
- minSize?: boolean;
1399
+ minSize?: boolean | undefined;
1403
1400
  /** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
1404
- mixed?: boolean;
1401
+ mixed?: boolean | undefined;
1405
1402
  /** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
1406
1403
  preset?: keyof PresetEnum | undefined;
1404
+ /** Preserve the colour data in transparent pixels (optional, default false) */
1405
+ exact?: boolean | undefined;
1407
1406
  }
1408
1407
 
1409
1408
  interface AvifOptions extends OutputOptions {
@@ -1417,13 +1416,15 @@ declare namespace sharp {
1417
1416
  chromaSubsampling?: string | undefined;
1418
1417
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1419
1418
  bitdepth?: 8 | 10 | 12 | undefined;
1419
+ /** Tune output for a quality metric, one of 'iq', 'ssim' or 'psnr' (optional, default 'iq') */
1420
+ tune?: HeifTune | undefined;
1420
1421
  }
1421
1422
 
1422
1423
  interface HeifOptions extends OutputOptions {
1423
1424
  /** quality, integer 1-100 (optional, default 50) */
1424
1425
  quality?: number | undefined;
1425
1426
  /** compression format: av1, hevc (optional, default 'av1') */
1426
- compression?: 'av1' | 'hevc' | undefined;
1427
+ compression?: HeifCompression | undefined;
1427
1428
  /** use lossless compression (optional, default false) */
1428
1429
  lossless?: boolean | undefined;
1429
1430
  /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
@@ -1432,6 +1433,8 @@ declare namespace sharp {
1432
1433
  chromaSubsampling?: string | undefined;
1433
1434
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1434
1435
  bitdepth?: 8 | 10 | 12 | undefined;
1436
+ /** Tune output for a quality metric, one of 'ssim', 'psnr' or 'iq' (optional, default 'ssim') */
1437
+ tune?: HeifTune | undefined;
1435
1438
  }
1436
1439
 
1437
1440
  interface GifOptions extends OutputOptions, AnimationOptions {
@@ -1476,12 +1479,12 @@ declare namespace sharp {
1476
1479
  xres?: number | undefined;
1477
1480
  /** Vertical resolution in pixels/mm (optional, default 1.0) */
1478
1481
  yres?: number | undefined;
1479
- /** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
1480
- bitdepth?: 1 | 2 | 4 | 8 | undefined;
1482
+ /** Reduce bitdepth to 1, 2 or 4 bit (optional) */
1483
+ bitdepth?: 1 | 2 | 4 | undefined;
1481
1484
  /** Write 1-bit images as miniswhite (optional, default false) */
1482
1485
  miniswhite?: boolean | undefined;
1483
1486
  /** Resolution unit options: inch, cm (optional, default 'inch') */
1484
- resolutionUnit?: 'inch' | 'cm' | undefined;
1487
+ resolutionUnit?: Unit | undefined;
1485
1488
  }
1486
1489
 
1487
1490
  interface PngOptions extends OutputOptions {
@@ -1603,10 +1606,12 @@ declare namespace sharp {
1603
1606
  threshold?: number | undefined;
1604
1607
  /** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
1605
1608
  lineArt?: boolean | undefined;
1609
+ /** Leave a margin around trimmed content, value is in pixels. (optional, default 0) */
1610
+ margin?: number | undefined;
1606
1611
  }
1607
1612
 
1608
1613
  interface RawOptions {
1609
- depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
1614
+ depth?: keyof DepthEnum;
1610
1615
  }
1611
1616
 
1612
1617
  /** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
@@ -1908,16 +1913,13 @@ declare namespace sharp {
1908
1913
  }
1909
1914
 
1910
1915
  interface FormatEnum {
1911
- avif: AvailableFormatInfo;
1912
1916
  dcraw: AvailableFormatInfo;
1913
1917
  dz: AvailableFormatInfo;
1914
1918
  exr: AvailableFormatInfo;
1915
1919
  fits: AvailableFormatInfo;
1916
1920
  gif: AvailableFormatInfo;
1917
1921
  heif: AvailableFormatInfo;
1918
- input: AvailableFormatInfo;
1919
1922
  jpeg: AvailableFormatInfo;
1920
- jpg: AvailableFormatInfo;
1921
1923
  jp2: AvailableFormatInfo;
1922
1924
  jxl: AvailableFormatInfo;
1923
1925
  magick: AvailableFormatInfo;
@@ -1929,8 +1931,7 @@ declare namespace sharp {
1929
1931
  raw: AvailableFormatInfo;
1930
1932
  svg: AvailableFormatInfo;
1931
1933
  tiff: AvailableFormatInfo;
1932
- tif: AvailableFormatInfo;
1933
- v: AvailableFormatInfo;
1934
+ vips: AvailableFormatInfo;
1934
1935
  webp: AvailableFormatInfo;
1935
1936
  }
1936
1937
 
package/lib/input.js CHANGED
@@ -30,7 +30,7 @@ const inputStreamParameters = [
30
30
  // Format-specific
31
31
  'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',
32
32
  // Deprecated
33
- 'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'
33
+ 'openSlideLevel', 'pdfBackground', 'tiffSubifd'
34
34
  ];
35
35
 
36
36
  /**
@@ -106,14 +106,6 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
106
106
  }`);
107
107
  }
108
108
  if (is.object(inputOptions)) {
109
- // Deprecated: failOnError
110
- if (is.defined(inputOptions.failOnError)) {
111
- if (is.bool(inputOptions.failOnError)) {
112
- inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';
113
- } else {
114
- throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);
115
- }
116
- }
117
109
  // failOn
118
110
  if (is.defined(inputOptions.failOn)) {
119
111
  if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {
@@ -570,17 +562,18 @@ function _isStreamInput () {
570
562
  * such as resize or rotate.
571
563
  *
572
564
  * Dimensions in the response will respect the `page` and `pages` properties of the
573
- * {@link /api-constructor#parameters|constructor parameters}.
565
+ * {@link /api-constructor/ constructor parameters}.
574
566
  *
575
567
  * A `Promise` is returned when `callback` is not provided.
576
568
  *
577
- * - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`
569
+ * - `format`: Name of decoder used to parse image e.g. `jpeg`, `png`, `webp`, `gif`, `svg`, `heif`, `tiff`
570
+ * - `mediaType`: Media Type (MIME Type) e.g. `image/jpeg`, `image/png`, `image/svg+xml`, `image/avif`
578
571
  * - `size`: Total size of image in bytes, for Stream and Buffer input only
579
572
  * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)
580
573
  * - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)
581
- * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/VipsImage.html#VipsInterpretation)
574
+ * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)
582
575
  * - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
583
- * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/VipsImage.html#VipsBandFormat)
576
+ * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/enum.BandFormat.html)
584
577
  * - `density`: Number of pixels per inch (DPI), if present
585
578
  * - `chromaSubsampling`: 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
586
579
  * - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan
@@ -607,6 +600,7 @@ function _isStreamInput () {
607
600
  * - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present
608
601
  * - `formatMagick`: String containing format for images loaded via *magick
609
602
  * - `comments`: Array of keyword/text pairs representing PNG text blocks, if present.
603
+ * - `gainMap.image`: HDR gain map, if present, as compressed JPEG image.
610
604
  *
611
605
  * @example
612
606
  * const metadata = await sharp(input).metadata();
@@ -792,7 +786,7 @@ function stats (callback) {
792
786
  * @module Sharp
793
787
  * @private
794
788
  */
795
- module.exports = function (Sharp) {
789
+ module.exports = (Sharp) => {
796
790
  Object.assign(Sharp.prototype, {
797
791
  // Private
798
792
  _inputOptionsFromObject,
package/lib/is.js CHANGED
@@ -7,55 +7,43 @@
7
7
  * Is this value defined and not null?
8
8
  * @private
9
9
  */
10
- const defined = function (val) {
11
- return typeof val !== 'undefined' && val !== null;
12
- };
10
+ const defined = (val) => typeof val !== 'undefined' && val !== null;
13
11
 
14
12
  /**
15
13
  * Is this value an object?
16
14
  * @private
17
15
  */
18
- const object = function (val) {
19
- return typeof val === 'object';
20
- };
16
+ const object = (val) => typeof val === 'object';
21
17
 
22
18
  /**
23
19
  * Is this value a plain object?
24
20
  * @private
25
21
  */
26
- const plainObject = function (val) {
27
- return Object.prototype.toString.call(val) === '[object Object]';
28
- };
22
+ const plainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
29
23
 
30
24
  /**
31
25
  * Is this value a function?
32
26
  * @private
33
27
  */
34
- const fn = function (val) {
35
- return typeof val === 'function';
36
- };
28
+ const fn = (val) => typeof val === 'function';
37
29
 
38
30
  /**
39
31
  * Is this value a boolean?
40
32
  * @private
41
33
  */
42
- const bool = function (val) {
43
- return typeof val === 'boolean';
44
- };
34
+ const bool = (val) => typeof val === 'boolean';
45
35
 
46
36
  /**
47
37
  * Is this value a Buffer object?
48
38
  * @private
49
39
  */
50
- const buffer = function (val) {
51
- return val instanceof Buffer;
52
- };
40
+ const buffer = (val) => val instanceof Buffer;
53
41
 
54
42
  /**
55
43
  * Is this value a typed array object?. E.g. Uint8Array or Uint8ClampedArray?
56
44
  * @private
57
45
  */
58
- const typedArray = function (val) {
46
+ const typedArray = (val) => {
59
47
  if (defined(val)) {
60
48
  switch (val.constructor) {
61
49
  case Uint8Array:
@@ -78,49 +66,37 @@ const typedArray = function (val) {
78
66
  * Is this value an ArrayBuffer object?
79
67
  * @private
80
68
  */
81
- const arrayBuffer = function (val) {
82
- return val instanceof ArrayBuffer;
83
- };
69
+ const arrayBuffer = (val) => val instanceof ArrayBuffer;
84
70
 
85
71
  /**
86
72
  * Is this value a non-empty string?
87
73
  * @private
88
74
  */
89
- const string = function (val) {
90
- return typeof val === 'string' && val.length > 0;
91
- };
75
+ const string = (val) => typeof val === 'string' && val.length > 0;
92
76
 
93
77
  /**
94
78
  * Is this value a real number?
95
79
  * @private
96
80
  */
97
- const number = function (val) {
98
- return typeof val === 'number' && !Number.isNaN(val);
99
- };
81
+ const number = (val) => typeof val === 'number' && !Number.isNaN(val);
100
82
 
101
83
  /**
102
84
  * Is this value an integer?
103
85
  * @private
104
86
  */
105
- const integer = function (val) {
106
- return Number.isInteger(val);
107
- };
87
+ const integer = (val) => Number.isInteger(val);
108
88
 
109
89
  /**
110
90
  * Is this value within an inclusive given range?
111
91
  * @private
112
92
  */
113
- const inRange = function (val, min, max) {
114
- return val >= min && val <= max;
115
- };
93
+ const inRange = (val, min, max) => val >= min && val <= max;
116
94
 
117
95
  /**
118
96
  * Is this value within the elements of an array?
119
97
  * @private
120
98
  */
121
- const inArray = function (val, list) {
122
- return list.includes(val);
123
- };
99
+ const inArray = (val, list) => list.includes(val);
124
100
 
125
101
  /**
126
102
  * Create an Error with a message relating to an invalid parameter.
@@ -131,11 +107,9 @@ const inArray = function (val, list) {
131
107
  * @returns {Error} Containing the formatted message.
132
108
  * @private
133
109
  */
134
- const invalidParameterError = function (name, expected, actual) {
135
- return new Error(
110
+ const invalidParameterError = (name, expected, actual) => new Error(
136
111
  `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
137
112
  );
138
- };
139
113
 
140
114
  /**
141
115
  * Ensures an Error from C++ contains a JS stack.
@@ -145,7 +119,7 @@ const invalidParameterError = function (name, expected, actual) {
145
119
  * @returns {Error} Error with message and stack.
146
120
  * @private
147
121
  */
148
- const nativeError = function (native, context) {
122
+ const nativeError = (native, context) => {
149
123
  context.message = native.message;
150
124
  return context;
151
125
  };