sharp 0.35.5 → 0.35.6-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/dist/channel.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/channel.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/colour.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -107,7 +107,7 @@ function pipelineColorspace (colorspace) {
107
107
  * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
108
108
  *
109
109
  * @example
110
- * // Output 16 bits per pixel RGB
110
+ * // Output 16 bits per channel RGB
111
111
  * await sharp(input)
112
112
  * .toColourspace('rgb16')
113
113
  * .toFile('16-bpp.png')
package/dist/colour.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -107,7 +107,7 @@ function pipelineColorspace (colorspace) {
107
107
  * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
108
108
  *
109
109
  * @example
110
- * // Output 16 bits per pixel RGB
110
+ * // Output 16 bits per channel RGB
111
111
  * await sharp(input)
112
112
  * .toColourspace('rgb16')
113
113
  * .toFile('16-bpp.png')
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -167,7 +167,7 @@ const queueListener = (queueLength) => {
167
167
  * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.
168
168
  * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
169
169
  * @param {number} [options.density=72] - The DPI at which to render SVG and PDF images, in the range 1 to 100000.
170
- * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
170
+ * @param {boolean} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
171
171
  * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.
172
172
  * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
173
173
  * @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`.
@@ -202,7 +202,7 @@ const queueListener = (queueLength) => {
202
202
  * @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'.
203
203
  * @param {Object} [options.join] - describes how an array of input images should be joined.
204
204
  * @param {number} [options.join.across=1] - number of images to join horizontally.
205
- * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.
205
+ * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image, cannot be used with `across` or `shim`.
206
206
  * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.
207
207
  * @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.
208
208
  * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -167,7 +167,7 @@ const queueListener = (queueLength) => {
167
167
  * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.
168
168
  * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
169
169
  * @param {number} [options.density=72] - The DPI at which to render SVG and PDF images, in the range 1 to 100000.
170
- * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
170
+ * @param {boolean} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
171
171
  * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.
172
172
  * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
173
173
  * @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`.
@@ -202,7 +202,7 @@ const queueListener = (queueLength) => {
202
202
  * @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'.
203
203
  * @param {Object} [options.join] - describes how an array of input images should be joined.
204
204
  * @param {number} [options.join.across=1] - number of images to join horizontally.
205
- * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.
205
+ * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image, cannot be used with `across` or `shim`.
206
206
  * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.
207
207
  * @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.
208
208
  * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ /* cspell:disable */
1
2
  /**
2
3
  * Copyright 2017 François Nguyen and others.
3
4
  *
@@ -22,6 +23,7 @@
22
23
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
24
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
  */
26
+ /* cspell:enable */
25
27
 
26
28
  // SPDX-License-Identifier: MIT
27
29
 
@@ -408,7 +410,7 @@ declare namespace sharp {
408
410
 
409
411
  /**
410
412
  * Alias for calling `rotate()` with no arguments, which orients the image based
411
- * on EXIF orientsion.
413
+ * on EXIF orientation.
412
414
  *
413
415
  * This operation is aliased to emphasize its purpose, helping to remove any
414
416
  * confusion between rotation and orientation.
@@ -580,7 +582,7 @@ declare namespace sharp {
580
582
  convolve(kernel: Kernel): Sharp;
581
583
 
582
584
  /**
583
- * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
585
+ * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
584
586
  * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
585
587
  * @param options threshold options
586
588
  * @throws {Error} Invalid parameters
@@ -785,8 +787,8 @@ declare namespace sharp {
785
787
 
786
788
  /**
787
789
  * Use these PNG options for output image.
788
- * PNG output is always full colour at 8 or 16 bits per pixel.
789
- * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
790
+ * PNG output is always full colour at 8 or 16 bits per channel.
791
+ * Indexed PNG input is converted to 8 bits per channel.
790
792
  * @param options Output options.
791
793
  * @throws {Error} Invalid options
792
794
  * @returns A sharp instance that can be used to chain operations
@@ -1460,8 +1462,8 @@ declare namespace sharp {
1460
1462
  interface HeifOptions extends OutputOptions {
1461
1463
  /** quality, integer 1-100 (optional, default 50) */
1462
1464
  quality?: number | undefined;
1463
- /** compression format: av1, hevc (optional, default 'av1') */
1464
- compression?: HeifCompression | undefined;
1465
+ /** compression format: av1, hevc */
1466
+ compression: HeifCompression;
1465
1467
  /** use lossless compression (optional, default false) */
1466
1468
  lossless?: boolean | undefined;
1467
1469
  /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
@@ -1470,7 +1472,7 @@ declare namespace sharp {
1470
1472
  chromaSubsampling?: string | undefined;
1471
1473
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1472
1474
  bitdepth?: 8 | 10 | 12 | undefined;
1473
- /** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
1475
+ /** Tune output for a quality metric, one of 'auto' (av1 default), 'iq' (av1 only), 'psnr' or 'ssim' (hevc default) */
1474
1476
  tune?: HeifTune | undefined;
1475
1477
  }
1476
1478
 
@@ -1699,7 +1701,7 @@ declare namespace sharp {
1699
1701
  left?: number | undefined;
1700
1702
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1701
1703
  tile?: boolean | undefined;
1702
- /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1704
+ /** Set to true to avoid premultiplying the image below. Equivalent to the --premultiplied vips option. */
1703
1705
  premultiplied?: boolean | undefined;
1704
1706
  /** number representing the DPI for vector overlay image. (optional, default 72)*/
1705
1707
  density?: number | undefined;
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ /* cspell:disable */
1
2
  /**
2
3
  * Copyright 2017 François Nguyen and others.
3
4
  *
@@ -22,6 +23,7 @@
22
23
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
24
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
  */
26
+ /* cspell:enable */
25
27
 
26
28
  // SPDX-License-Identifier: MIT
27
29
 
@@ -402,7 +404,7 @@ export interface Sharp extends Duplex {
402
404
 
403
405
  /**
404
406
  * Alias for calling `rotate()` with no arguments, which orients the image based
405
- * on EXIF orientsion.
407
+ * on EXIF orientation.
406
408
  *
407
409
  * This operation is aliased to emphasize its purpose, helping to remove any
408
410
  * confusion between rotation and orientation.
@@ -574,7 +576,7 @@ export interface Sharp extends Duplex {
574
576
  convolve(kernel: Kernel): Sharp;
575
577
 
576
578
  /**
577
- * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
579
+ * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
578
580
  * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
579
581
  * @param options threshold options
580
582
  * @throws {Error} Invalid parameters
@@ -779,8 +781,8 @@ export interface Sharp extends Duplex {
779
781
 
780
782
  /**
781
783
  * Use these PNG options for output image.
782
- * PNG output is always full colour at 8 or 16 bits per pixel.
783
- * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
784
+ * PNG output is always full colour at 8 or 16 bits per channel.
785
+ * Indexed PNG input is converted to 8 bits per channel.
784
786
  * @param options Output options.
785
787
  * @throws {Error} Invalid options
786
788
  * @returns A sharp instance that can be used to chain operations
@@ -1454,8 +1456,8 @@ export interface AvifOptions extends OutputOptions {
1454
1456
  export interface HeifOptions extends OutputOptions {
1455
1457
  /** quality, integer 1-100 (optional, default 50) */
1456
1458
  quality?: number | undefined;
1457
- /** compression format: av1, hevc (optional, default 'av1') */
1458
- compression?: HeifCompression | undefined;
1459
+ /** compression format: av1, hevc */
1460
+ compression: HeifCompression;
1459
1461
  /** use lossless compression (optional, default false) */
1460
1462
  lossless?: boolean | undefined;
1461
1463
  /** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
@@ -1464,7 +1466,7 @@ export interface HeifOptions extends OutputOptions {
1464
1466
  chromaSubsampling?: string | undefined;
1465
1467
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1466
1468
  bitdepth?: 8 | 10 | 12 | undefined;
1467
- /** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
1469
+ /** Tune output for a quality metric, one of 'auto' (av1 default), 'iq' (av1 only), 'psnr' or 'ssim' (hevc default) */
1468
1470
  tune?: HeifTune | undefined;
1469
1471
  }
1470
1472
 
@@ -1693,7 +1695,7 @@ export interface OverlayOptions extends SharpOptions {
1693
1695
  left?: number | undefined;
1694
1696
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1695
1697
  tile?: boolean | undefined;
1696
- /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1698
+ /** Set to true to avoid premultiplying the image below. Equivalent to the --premultiplied vips option. */
1697
1699
  premultiplied?: boolean | undefined;
1698
1700
  /** number representing the DPI for vector overlay image. (optional, default 72)*/
1699
1701
  density?: number | undefined;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/input.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -94,7 +94,11 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
94
94
  // Join images together
95
95
  if (!this.options.joining) {
96
96
  this.options.joining = true;
97
- this.options.join = input.map(i => this._createInputDescriptor(i));
97
+ // Apply input options to each image being joined
98
+ const joinOptions = is.object(inputOptions) ? _inputOptionsFromObject(inputOptions) : undefined;
99
+ this.options.join = input.map(i => is.plainObject(i)
100
+ ? this._createInputDescriptor({ ...joinOptions, ...i })
101
+ : this._createInputDescriptor(i, joinOptions));
98
102
  } else {
99
103
  throw new Error('Recursive join is unsupported');
100
104
  }
@@ -511,6 +515,9 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
511
515
  throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);
512
516
  }
513
517
  }
518
+ if (inputDescriptor.joinAnimated && (inputDescriptor.joinAcross > 1 || inputDescriptor.joinShim > 0)) {
519
+ throw new Error('Expected neither join.across nor join.shim when join.animated is set');
520
+ }
514
521
  } else {
515
522
  throw new Error('Expected input to be an array of images to join');
516
523
  }
package/dist/input.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -94,7 +94,11 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
94
94
  // Join images together
95
95
  if (!this.options.joining) {
96
96
  this.options.joining = true;
97
- this.options.join = input.map(i => this._createInputDescriptor(i));
97
+ // Apply input options to each image being joined
98
+ const joinOptions = is.object(inputOptions) ? _inputOptionsFromObject(inputOptions) : undefined;
99
+ this.options.join = input.map(i => is.plainObject(i)
100
+ ? this._createInputDescriptor({ ...joinOptions, ...i })
101
+ : this._createInputDescriptor(i, joinOptions));
98
102
  } else {
99
103
  throw new Error('Recursive join is unsupported');
100
104
  }
@@ -511,6 +515,9 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
511
515
  throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);
512
516
  }
513
517
  }
518
+ if (inputDescriptor.joinAnimated && (inputDescriptor.joinAcross > 1 || inputDescriptor.joinShim > 0)) {
519
+ throw new Error('Expected neither join.across nor join.shim when join.animated is set');
520
+ }
514
521
  } else {
515
522
  throw new Error('Expected input to be an array of images to join');
516
523
  }
package/dist/is.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -13,7 +13,7 @@ const defined = (val) => typeof val !== 'undefined' && val !== null;
13
13
  * Is this value an object?
14
14
  * @private
15
15
  */
16
- const object = (val) => typeof val === 'object';
16
+ const object = (val) => typeof val === 'object' && val !== null;
17
17
 
18
18
  /**
19
19
  * Is this value a plain object?
package/dist/is.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -13,7 +13,7 @@ const defined = (val) => typeof val !== 'undefined' && val !== null;
13
13
  * Is this value an object?
14
14
  * @private
15
15
  */
16
- const object = (val) => typeof val === 'object';
16
+ const object = (val) => typeof val === 'object' && val !== null;
17
17
 
18
18
  /**
19
19
  * Is this value a plain object?
package/dist/libvips.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/libvips.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -62,7 +62,7 @@ function rotate (angle, options) {
62
62
  this.options.rotationAngle = 0;
63
63
  }
64
64
  if (is.integer(angle) && !(angle % 90)) {
65
- this.options.angle = angle;
65
+ this.options.angle = angle % 360;
66
66
  } else if (is.number(angle)) {
67
67
  this.options.rotationAngle = angle;
68
68
  if (is.object(options) && options.background) {
@@ -384,7 +384,7 @@ function blur (options) {
384
384
  sigma = options;
385
385
  } else if (is.plainObject(options)) {
386
386
  if (!is.number(options.sigma)) {
387
- throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', sigma);
387
+ throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', options.sigma);
388
388
  }
389
389
  sigma = options.sigma;
390
390
  if ('precision' in options) {
@@ -413,7 +413,7 @@ function blur (options) {
413
413
  // Numeric argument: specific sigma
414
414
  this.options.blurSigma = sigma;
415
415
  } else {
416
- throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', sigma);
416
+ throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', options);
417
417
  }
418
418
 
419
419
  return this;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -62,7 +62,7 @@ function rotate (angle, options) {
62
62
  this.options.rotationAngle = 0;
63
63
  }
64
64
  if (is.integer(angle) && !(angle % 90)) {
65
- this.options.angle = angle;
65
+ this.options.angle = angle % 360;
66
66
  } else if (is.number(angle)) {
67
67
  this.options.rotationAngle = angle;
68
68
  if (is.object(options) && options.background) {
@@ -384,7 +384,7 @@ function blur (options) {
384
384
  sigma = options;
385
385
  } else if (is.plainObject(options)) {
386
386
  if (!is.number(options.sigma)) {
387
- throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', sigma);
387
+ throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', options.sigma);
388
388
  }
389
389
  sigma = options.sigma;
390
390
  if ('precision' in options) {
@@ -413,7 +413,7 @@ function blur (options) {
413
413
  // Numeric argument: specific sigma
414
414
  this.options.blurSigma = sigma;
415
415
  } else {
416
- throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', sigma);
416
+ throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', options);
417
417
  }
418
418
 
419
419
  return this;
package/dist/output.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -205,15 +205,15 @@ function toUint8Array () {
205
205
  * .withDensity(96)
206
206
  * .toBuffer();
207
207
  *
208
- * @param {number} density Number of pixels per inch (DPI).
208
+ * @param {number} density Number of pixels per inch (DPI), between 1 and 100000.
209
209
  * @returns {Sharp}
210
210
  * @throws {Error} Invalid parameters
211
211
  */
212
212
  function withDensity (density) {
213
- if (is.number(density) && density > 0) {
213
+ if (is.number(density) && is.inRange(density, 1, 100000)) {
214
214
  this.options.withMetadataDensity = density;
215
215
  } else {
216
- throw is.invalidParameterError('density', 'positive number', density);
216
+ throw is.invalidParameterError('density', 'number between 1 and 100000', density);
217
217
  }
218
218
  return this.keepExif();
219
219
  }
@@ -264,9 +264,12 @@ function keepExif () {
264
264
  function withExif (exif) {
265
265
  if (is.object(exif)) {
266
266
  for (const [ifd, entries] of Object.entries(exif)) {
267
+ if (!is.string(ifd) || !ifd.toLowerCase().startsWith('ifd')) {
268
+ throw is.invalidParameterError('exif', 'object with IFD-prefixed string keys', exif);
269
+ }
267
270
  if (is.object(entries)) {
268
271
  for (const [k, v] of Object.entries(entries)) {
269
- if (is.string(v)) {
272
+ if (is.string(k) && is.string(v)) {
270
273
  this.options.withExif[`exif-${ifd.toLowerCase()}-${k}`] = v;
271
274
  } else {
272
275
  throw is.invalidParameterError(`${ifd}.${k}`, 'string', v);
@@ -348,7 +351,7 @@ function keepIccProfile () {
348
351
  *
349
352
  * @param {string} icc - Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk).
350
353
  * @param {Object} [options]
351
- * @param {number} [options.attach=true] Should the ICC profile be included in the output image metadata?
354
+ * @param {boolean} [options.attach=true] Should the ICC profile be included in the output image metadata?
352
355
  * @returns {Sharp}
353
356
  * @throws {Error} Invalid parameters
354
357
  */
@@ -520,7 +523,7 @@ function keepMetadata () {
520
523
  *
521
524
  * @param {Object} [options]
522
525
  * @param {number} [options.orientation] Used to update the EXIF `Orientation` tag, integer between 1 and 8.
523
- * @param {number} [options.density] Number of pixels per inch (DPI).
526
+ * @param {number} [options.density] Number of pixels per inch (DPI), between 1 and 100000.
524
527
  * @returns {Sharp}
525
528
  * @throws {Error} Invalid parameters
526
529
  */
@@ -536,10 +539,10 @@ function withMetadata (options) {
536
539
  }
537
540
  }
538
541
  if (is.defined(options.density)) {
539
- if (is.number(options.density) && options.density > 0) {
542
+ if (is.number(options.density) && is.inRange(options.density, 1, 100000)) {
540
543
  this.options.withMetadataDensity = options.density;
541
544
  } else {
542
- throw is.invalidParameterError('density', 'positive number', options.density);
545
+ throw is.invalidParameterError('density', 'number between 1 and 100000', options.density);
543
546
  }
544
547
  }
545
548
  if (is.defined(options.icc)) {
@@ -598,10 +601,10 @@ function toFormat (format, options) {
598
601
  * @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling
599
602
  * @param {boolean} [options.optimiseCoding=true] - optimise Huffman coding tables
600
603
  * @param {boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding
601
- * @param {boolean} [options.mozjpeg=false] - use mozjpeg defaults, equivalent to `{ trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }`
602
- * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation
604
+ * @param {boolean} [options.mozjpeg=false] - use mozjpeg defaults, equivalent to `{ trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, progressive: true, quantisationTable: 3 }` (may increase processing time by about 75%)
605
+ * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation (may increase processing time by about 45%)
603
606
  * @param {boolean} [options.overshootDeringing=false] - apply overshoot deringing
604
- * @param {boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive
607
+ * @param {boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive (may increase processing time by about 40%)
605
608
  * @param {boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans
606
609
  * @param {number} [options.quantisationTable=0] - quantization table to use, integer 0-8
607
610
  * @param {number} [options.quantizationTable=0] - alternative spelling of quantisationTable
@@ -674,12 +677,12 @@ function jpeg (options) {
674
677
  /**
675
678
  * Use these PNG options for output image.
676
679
  *
677
- * By default, PNG output is full colour at 8 bits per pixel.
680
+ * By default, PNG output is full colour at 8 bits per channel.
678
681
  *
679
- * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.
682
+ * Indexed PNG input is converted to 8 bits per channel.
680
683
  * Set `palette` to `true` for slower, indexed PNG output.
681
684
  *
682
- * For 16 bits per pixel output, convert to `rgb16` via
685
+ * For 16 bits per channel output, convert to `rgb16` via
683
686
  * {@link /api-colour/#tocolourspace toColourspace}.
684
687
  *
685
688
  * @example
@@ -695,7 +698,7 @@ function jpeg (options) {
695
698
  * .toBuffer();
696
699
  *
697
700
  * @example
698
- * // Output 16 bits per pixel RGB(A)
701
+ * // Output 16 bits per channel RGB(A)
699
702
  * const data = await sharp(input)
700
703
  * .toColourspace('rgb16')
701
704
  * .png()
@@ -1250,7 +1253,7 @@ function avif (options) {
1250
1253
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1251
1254
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1252
1255
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1253
- * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (default), 'iq', 'psnr' or 'ssim'
1256
+ * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (av1 default), 'iq' (av1 only), 'psnr' or 'ssim' (hevc default)
1254
1257
  * @returns {Sharp}
1255
1258
  * @throws {Error} Invalid options
1256
1259
  */
@@ -1258,6 +1261,9 @@ function heif (options) {
1258
1261
  if (is.object(options)) {
1259
1262
  if (is.string(options.compression) && is.inArray(options.compression, ['av1', 'hevc'])) {
1260
1263
  this.options.heifCompression = options.compression;
1264
+ if (options.compression === 'hevc' && this.options.heifTune === 'auto') {
1265
+ this.options.heifTune = 'ssim';
1266
+ }
1261
1267
  } else {
1262
1268
  throw is.invalidParameterError('compression', 'one of: av1, hevc', options.compression);
1263
1269
  }
@@ -1297,14 +1303,24 @@ function heif (options) {
1297
1303
  }
1298
1304
  }
1299
1305
  if (is.defined(options.tune)) {
1300
- if (is.string(options.tune) && is.inArray(options.tune, ['auto', 'iq', 'psnr', 'ssim'])) {
1301
- if (this.options.heifLossless && options.tune === 'iq') {
1302
- this.options.heifTune = 'ssim';
1303
- } else {
1306
+ if (is.string(options.tune)) {
1307
+ if (this.options.heifCompression === 'av1') {
1308
+ if (is.inArray(options.tune, ['auto', 'iq', 'psnr', 'ssim'])) {
1309
+ if (this.options.heifLossless && options.tune === 'iq') {
1310
+ this.options.heifTune = 'ssim';
1311
+ } else {
1312
+ this.options.heifTune = options.tune;
1313
+ }
1314
+ } else {
1315
+ throw is.invalidParameterError('tune', 'one of: auto, iq, psnr, ssim', options.tune);
1316
+ }
1317
+ } else if (is.inArray(options.tune, ['psnr', 'ssim'])) {
1304
1318
  this.options.heifTune = options.tune;
1319
+ } else {
1320
+ throw is.invalidParameterError('tune', 'one of: psnr, ssim', options.tune);
1305
1321
  }
1306
1322
  } else {
1307
- throw is.invalidParameterError('tune', 'one of: auto, iq, psnr, ssim', options.tune);
1323
+ throw is.invalidParameterError('tune', 'string', options.tune);
1308
1324
  }
1309
1325
  }
1310
1326
  } else {
@@ -1505,7 +1521,7 @@ function tile (options) {
1505
1521
  // Angle of rotation,
1506
1522
  if (is.defined(options.angle)) {
1507
1523
  if (is.integer(options.angle) && !(options.angle % 90)) {
1508
- this.options.tileAngle = options.angle;
1524
+ this.options.tileAngle = options.angle % 360;
1509
1525
  } else {
1510
1526
  throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);
1511
1527
  }