sharp 0.35.5-rc.1 → 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/output.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
 
@@ -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
  }
package/dist/resize.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
 
@@ -52,7 +52,7 @@ const extendWith = {
52
52
  };
53
53
 
54
54
  /**
55
- * Strategies for automagic cover behaviour.
55
+ * Strategies for cover behaviour.
56
56
  * @member
57
57
  * @private
58
58
  */
@@ -483,14 +483,18 @@ function extract (options) {
483
483
  if (this.options[`width${suffix}`] !== -1) {
484
484
  this.options.debuglog('ignoring previous extract options');
485
485
  }
486
- ['left', 'top', 'width', 'height'].forEach(function (name) {
487
- const value = options[name];
488
- if (is.integer(value) && is.inRange(value, 0, 100000000)) {
489
- this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
490
- } else {
491
- throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
492
- }
493
- }, this);
486
+ if (is.plainObject(options)) {
487
+ ['left', 'top', 'width', 'height'].forEach(function (name) {
488
+ const value = options[name];
489
+ if (is.integer(value) && is.inRange(value, 0, 100000000)) {
490
+ this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
491
+ } else {
492
+ throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
493
+ }
494
+ }, this);
495
+ } else {
496
+ throw is.invalidParameterError('options', 'plain object', options);
497
+ }
494
498
  // Ensure existing rotation occurs before pre-resize extraction
495
499
  if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {
496
500
  if (this.options.widthPre === -1 || this.options.widthPost === -1) {
package/dist/resize.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
 
@@ -52,7 +52,7 @@ const extendWith = {
52
52
  };
53
53
 
54
54
  /**
55
- * Strategies for automagic cover behaviour.
55
+ * Strategies for cover behaviour.
56
56
  * @member
57
57
  * @private
58
58
  */
@@ -483,14 +483,18 @@ function extract (options) {
483
483
  if (this.options[`width${suffix}`] !== -1) {
484
484
  this.options.debuglog('ignoring previous extract options');
485
485
  }
486
- ['left', 'top', 'width', 'height'].forEach(function (name) {
487
- const value = options[name];
488
- if (is.integer(value) && is.inRange(value, 0, 100000000)) {
489
- this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
490
- } else {
491
- throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
492
- }
493
- }, this);
486
+ if (is.plainObject(options)) {
487
+ ['left', 'top', 'width', 'height'].forEach(function (name) {
488
+ const value = options[name];
489
+ if (is.integer(value) && is.inRange(value, 0, 100000000)) {
490
+ this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
491
+ } else {
492
+ throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
493
+ }
494
+ }, this);
495
+ } else {
496
+ throw is.invalidParameterError('options', 'plain object', options);
497
+ }
494
498
  // Ensure existing rotation occurs before pre-resize extraction
495
499
  if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {
496
500
  if (this.options.widthPre === -1 || this.options.widthPost === -1) {
package/dist/sharp.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/sharp.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/utility.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/utility.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/install/build.js 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/lib/index.d.ts 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sharp",
3
3
  "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
4
- "version": "0.35.5-rc.1",
4
+ "version": "0.35.6-rc.0",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -98,10 +98,11 @@
98
98
  "build:dist": "node scripts/build.mjs",
99
99
  "clean": "rm -rf src/build/ test/fixtures/output.*",
100
100
  "test": "npm run lint && npm run test-unit",
101
- "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-publish",
101
+ "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-spell && npm run lint-publish",
102
102
  "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
103
103
  "lint-js": "biome lint",
104
104
  "lint-publish": "publint --strict",
105
+ "lint-spell": "cspell --config ./test/spell/cspell.jsonc --no-progress .",
105
106
  "lint-types": "tsd --files ./test/types/sharp.test-d.{cts,mts}",
106
107
  "test-leak": "./test/leak/leak.sh",
107
108
  "test-unit": "node --experimental-test-coverage test/unit.mjs",
@@ -160,34 +161,34 @@
160
161
  "dependencies": {
161
162
  "@img/colour": "^1.1.0",
162
163
  "detect-libc": "^2.1.2",
163
- "semver": "^7.8.5"
164
+ "semver": "^7.8.6"
164
165
  },
165
166
  "optionalDependencies": {
166
- "@img/sharp-darwin-arm64": "0.35.5-rc.1",
167
- "@img/sharp-darwin-x64": "0.35.5-rc.1",
168
- "@img/sharp-freebsd-wasm32": "0.35.5-rc.1",
169
- "@img/sharp-libvips-darwin-arm64": "1.3.4-rc.1",
170
- "@img/sharp-libvips-darwin-x64": "1.3.4-rc.1",
171
- "@img/sharp-libvips-linux-arm": "1.3.4-rc.1",
172
- "@img/sharp-libvips-linux-arm64": "1.3.4-rc.1",
173
- "@img/sharp-libvips-linux-ppc64": "1.3.4-rc.1",
174
- "@img/sharp-libvips-linux-riscv64": "1.3.4-rc.1",
175
- "@img/sharp-libvips-linux-s390x": "1.3.4-rc.1",
176
- "@img/sharp-libvips-linux-x64": "1.3.4-rc.1",
177
- "@img/sharp-libvips-linuxmusl-arm64": "1.3.4-rc.1",
178
- "@img/sharp-libvips-linuxmusl-x64": "1.3.4-rc.1",
179
- "@img/sharp-linux-arm": "0.35.5-rc.1",
180
- "@img/sharp-linux-arm64": "0.35.5-rc.1",
181
- "@img/sharp-linux-ppc64": "0.35.5-rc.1",
182
- "@img/sharp-linux-riscv64": "0.35.5-rc.1",
183
- "@img/sharp-linux-s390x": "0.35.5-rc.1",
184
- "@img/sharp-linux-x64": "0.35.5-rc.1",
185
- "@img/sharp-linuxmusl-arm64": "0.35.5-rc.1",
186
- "@img/sharp-linuxmusl-x64": "0.35.5-rc.1",
187
- "@img/sharp-webcontainers-wasm32": "0.35.5-rc.1",
188
- "@img/sharp-win32-arm64": "0.35.5-rc.1",
189
- "@img/sharp-win32-ia32": "0.35.5-rc.1",
190
- "@img/sharp-win32-x64": "0.35.5-rc.1"
167
+ "@img/sharp-darwin-arm64": "0.35.6-rc.0",
168
+ "@img/sharp-darwin-x64": "0.35.6-rc.0",
169
+ "@img/sharp-freebsd-wasm32": "0.35.6-rc.0",
170
+ "@img/sharp-libvips-darwin-arm64": "1.3.5-rc.1",
171
+ "@img/sharp-libvips-darwin-x64": "1.3.5-rc.1",
172
+ "@img/sharp-libvips-linux-arm": "1.3.5-rc.1",
173
+ "@img/sharp-libvips-linux-arm64": "1.3.5-rc.1",
174
+ "@img/sharp-libvips-linux-ppc64": "1.3.5-rc.1",
175
+ "@img/sharp-libvips-linux-riscv64": "1.3.5-rc.1",
176
+ "@img/sharp-libvips-linux-s390x": "1.3.5-rc.1",
177
+ "@img/sharp-libvips-linux-x64": "1.3.5-rc.1",
178
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.5-rc.1",
179
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.5-rc.1",
180
+ "@img/sharp-linux-arm": "0.35.6-rc.0",
181
+ "@img/sharp-linux-arm64": "0.35.6-rc.0",
182
+ "@img/sharp-linux-ppc64": "0.35.6-rc.0",
183
+ "@img/sharp-linux-riscv64": "0.35.6-rc.0",
184
+ "@img/sharp-linux-s390x": "0.35.6-rc.0",
185
+ "@img/sharp-linux-x64": "0.35.6-rc.0",
186
+ "@img/sharp-linuxmusl-arm64": "0.35.6-rc.0",
187
+ "@img/sharp-linuxmusl-x64": "0.35.6-rc.0",
188
+ "@img/sharp-webcontainers-wasm32": "0.35.6-rc.0",
189
+ "@img/sharp-win32-arm64": "0.35.6-rc.0",
190
+ "@img/sharp-win32-ia32": "0.35.6-rc.0",
191
+ "@img/sharp-win32-x64": "0.35.6-rc.0"
191
192
  },
192
193
  "peerDependenciesMeta": {
193
194
  "@types/node": {
@@ -195,22 +196,23 @@
195
196
  }
196
197
  },
197
198
  "devDependencies": {
198
- "@biomejs/biome": "^2.5.14",
199
+ "@biomejs/biome": "^2.6.9",
199
200
  "@cpplint/cli": "^0.1.0",
200
201
  "@emnapi/runtime": "^1.11.3",
201
- "@img/sharp-libvips-dev": "1.3.4-rc.1",
202
- "@img/sharp-libvips-dev-wasm32": "1.3.4-rc.1",
203
- "@img/sharp-libvips-win32-arm64": "1.3.4-rc.1",
204
- "@img/sharp-libvips-win32-ia32": "1.3.4-rc.1",
205
- "@img/sharp-libvips-win32-x64": "1.3.4-rc.1",
202
+ "@img/sharp-libvips-dev": "1.3.5-rc.1",
203
+ "@img/sharp-libvips-dev-wasm32": "1.3.5-rc.1",
204
+ "@img/sharp-libvips-win32-arm64": "1.3.5-rc.1",
205
+ "@img/sharp-libvips-win32-ia32": "1.3.5-rc.1",
206
+ "@img/sharp-libvips-win32-x64": "1.3.5-rc.1",
206
207
  "@types/node": "*",
208
+ "cspell": "^10.5.2",
207
209
  "emnapi": "^1.11.3",
208
210
  "exif-reader": "^2.0.3",
209
211
  "icc": "^4.0.0",
210
212
  "node-addon-api": "^8.9.2",
211
213
  "node-gyp": "^12.4.0",
212
- "publint": "^0.3.24",
213
- "tar-fs": "^3.1.3",
214
+ "publint": "^0.3.25",
215
+ "tar-fs": "^3.1.4",
214
216
  "tsd": "^0.33.0",
215
217
  "yauzl": "^3.4.0"
216
218
  },
@@ -219,7 +221,7 @@
219
221
  "node": ">=20.9.0"
220
222
  },
221
223
  "config": {
222
- "libvips": ">=8.18.7"
224
+ "libvips": ">=8.18.8"
223
225
  },
224
226
  "funding": {
225
227
  "url": "https://opencollective.com/libvips"
package/src/binding.gyp CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2013 Lovell Fuller and others.
1
+ # SPDX-FileCopyrightText: 2013 Lovell Fuller and others
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  { # noqa: B018
package/src/common.cc 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
 
@@ -198,7 +198,7 @@ namespace sharp {
198
198
  }
199
199
  descriptor->limitInputPixels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputPixels"));
200
200
  descriptor->limitInputChannels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputChannels"));
201
- if (HasAttr(input, "access")) {
201
+ if (HasAttr(input, "sequentialRead")) {
202
202
  descriptor->access = AttrAsBool(input, "sequentialRead") ? VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM;
203
203
  }
204
204
  // Remove safety features and allow unlimited input
@@ -399,6 +399,7 @@ namespace sharp {
399
399
  imageType == ImageType::JP2 ||
400
400
  imageType == ImageType::TIFF ||
401
401
  imageType == ImageType::HEIF ||
402
+ imageType == ImageType::JXL ||
402
403
  imageType == ImageType::PDF;
403
404
  }
404
405
 
@@ -635,7 +636,7 @@ namespace sharp {
635
636
  if (HasProfile(image)) {
636
637
  size_t length;
637
638
  const void *data = image.get_blob(VIPS_META_ICC_NAME, &length);
638
- icc.first = static_cast<char*>(vips_malloc(reinterpret_cast<VipsObject*>(image.get_image()), length));
639
+ icc.first = static_cast<char*>(g_malloc(length));
639
640
  icc.second = length;
640
641
  memcpy(icc.first, data, length);
641
642
  }
@@ -648,7 +649,7 @@ namespace sharp {
648
649
  VImage SetProfile(VImage image, std::pair<char*, size_t> icc) {
649
650
  if (icc.first != nullptr) {
650
651
  image = image.copy();
651
- image.set(VIPS_META_ICC_NAME, nullptr, icc.first, icc.second);
652
+ image.set(VIPS_META_ICC_NAME, reinterpret_cast<VipsCallbackFn>(vips_area_free_cb), icc.first, icc.second);
652
653
  }
653
654
  return image;
654
655
  }
@@ -720,7 +721,7 @@ namespace sharp {
720
721
  if (hasDelay) {
721
722
  if (delay.size() == 1) {
722
723
  // We have just one delay, repeat that value for all frames.
723
- delay.insert(delay.end(), nPages - 1, delay[0]);
724
+ delay.insert(delay.end(), std::max(0, nPages - 1), delay[0]);
724
725
  }
725
726
  copy.set("delay", delay);
726
727
  }
@@ -1166,21 +1167,4 @@ namespace sharp {
1166
1167
  return image;
1167
1168
  }
1168
1169
 
1169
- /*
1170
- Does this image have a gain map?
1171
- */
1172
- bool HasGainMap(VImage image) {
1173
- return image.get_typeof("gainmap") == VIPS_TYPE_BLOB ||
1174
- image.get_typeof("gainmap-data") == VIPS_TYPE_BLOB;
1175
- }
1176
-
1177
- /*
1178
- Removes gain map, if any.
1179
- */
1180
- VImage RemoveGainMap(VImage image) {
1181
- VImage copy = image.copy();
1182
- copy.remove("gainmap");
1183
- copy.remove("gainmap-data");
1184
- return copy;
1185
- }
1186
1170
  } // namespace sharp
package/src/common.h 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
 
@@ -19,8 +19,8 @@
19
19
 
20
20
  #if (VIPS_MAJOR_VERSION < 8) || \
21
21
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 18) || \
22
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 7)
23
- #error "libvips version 8.18.7+ is required - please see https://sharp.pixelplumbing.com/install"
22
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 8)
23
+ #error "libvips version 8.18.8+ is required - please see https://sharp.pixelplumbing.com/install"
24
24
  #endif
25
25
 
26
26
  #if defined(__has_include)
@@ -406,16 +406,6 @@ namespace sharp {
406
406
  */
407
407
  VImage StaySequential(VImage image, bool condition = true);
408
408
 
409
- /*
410
- Does this image have a gain map?
411
- */
412
- bool HasGainMap(VImage image);
413
-
414
- /*
415
- Removes gain map, if any.
416
- */
417
- VImage RemoveGainMap(VImage image);
418
-
419
409
  } // namespace sharp
420
410
 
421
411
  #endif // SRC_COMMON_H_
package/src/metadata.cc 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
 
@@ -32,7 +32,17 @@ class MetadataWorker : public Napi::AsyncWorker {
32
32
  try {
33
33
  std::tie(image, imageType) = OpenInput(baton->input);
34
34
  } catch (std::runtime_error const &err) {
35
- (baton->err).append(err.what());
35
+ char const *what = err.what();
36
+ if (what && what[0]) {
37
+ (baton->err).append(what);
38
+ } else {
39
+ if (baton->input->failOn == VIPS_FAIL_ON_WARNING) {
40
+ (baton->err).append("Warning treated as error due to failOn setting");
41
+ baton->errUseWarning = true;
42
+ } else {
43
+ (baton->err).append("Unknown error");
44
+ }
45
+ }
36
46
  }
37
47
  if (imageType != sharp::ImageType::UNKNOWN) {
38
48
  // Image type
@@ -209,7 +219,11 @@ class MetadataWorker : public Napi::AsyncWorker {
209
219
  // Handle warnings
210
220
  std::string warning = sharp::VipsWarningPop();
211
221
  while (!warning.empty()) {
212
- debuglog.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { Napi::String::New(env, warning) });
222
+ if (baton->errUseWarning) {
223
+ (baton->err).append("\n").append(warning);
224
+ } else {
225
+ debuglog.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { Napi::String::New(env, warning) });
226
+ }
213
227
  warning = sharp::VipsWarningPop();
214
228
  }
215
229