@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/lib/operation.js CHANGED
@@ -239,7 +239,7 @@ function affine (matrix, options) {
239
239
  * When a `sigma` is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
240
240
  * Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
241
241
  *
242
- * See {@link https://www.libvips.org/API/current/libvips-convolution.html#vips-sharpen|libvips sharpen} operation.
242
+ * See {@link https://www.libvips.org/API/current/method.Image.sharpen.html libvips sharpen} operation.
243
243
  *
244
244
  * @example
245
245
  * const data = await sharp(input).sharpen().toBuffer();
@@ -259,45 +259,18 @@ function affine (matrix, options) {
259
259
  * })
260
260
  * .toBuffer();
261
261
  *
262
- * @param {Object|number} [options] - if present, is an Object with attributes
262
+ * @param {Object} [options] - if present, is an Object with attributes
263
263
  * @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10
264
264
  * @param {number} [options.m1=1.0] - the level of sharpening to apply to "flat" areas, between 0 and 1000000
265
265
  * @param {number} [options.m2=2.0] - the level of sharpening to apply to "jagged" areas, between 0 and 1000000
266
266
  * @param {number} [options.x1=2.0] - threshold between "flat" and "jagged", between 0 and 1000000
267
267
  * @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000
268
268
  * @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000
269
- * @param {number} [flat] - (deprecated) see `options.m1`.
270
- * @param {number} [jagged] - (deprecated) see `options.m2`.
271
269
  * @returns {Sharp}
272
270
  * @throws {Error} Invalid parameters
273
271
  */
274
- function sharpen (options, flat, jagged) {
275
- if (!is.defined(options)) {
276
- // No arguments: default to mild sharpen
277
- this.options.sharpenSigma = -1;
278
- } else if (is.bool(options)) {
279
- // Deprecated boolean argument: apply mild sharpen?
280
- this.options.sharpenSigma = options ? -1 : 0;
281
- } else if (is.number(options) && is.inRange(options, 0.01, 10000)) {
282
- // Deprecated numeric argument: specific sigma
283
- this.options.sharpenSigma = options;
284
- // Deprecated control over flat areas
285
- if (is.defined(flat)) {
286
- if (is.number(flat) && is.inRange(flat, 0, 10000)) {
287
- this.options.sharpenM1 = flat;
288
- } else {
289
- throw is.invalidParameterError('flat', 'number between 0 and 10000', flat);
290
- }
291
- }
292
- // Deprecated control over jagged areas
293
- if (is.defined(jagged)) {
294
- if (is.number(jagged) && is.inRange(jagged, 0, 10000)) {
295
- this.options.sharpenM2 = jagged;
296
- } else {
297
- throw is.invalidParameterError('jagged', 'number between 0 and 10000', jagged);
298
- }
299
- }
300
- } else if (is.plainObject(options)) {
272
+ function sharpen (options) {
273
+ if (is.plainObject(options)) {
301
274
  if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {
302
275
  this.options.sharpenSigma = options.sigma;
303
276
  } else {
@@ -339,7 +312,7 @@ function sharpen (options, flat, jagged) {
339
312
  }
340
313
  }
341
314
  } else {
342
- throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);
315
+ this.options.sharpenSigma = -1;
343
316
  }
344
317
  return this;
345
318
  }
@@ -485,7 +458,7 @@ function erode (width) {
485
458
  /**
486
459
  * Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
487
460
  *
488
- * See also {@link /api-channel#removealpha|removeAlpha}.
461
+ * See also {@link /api-channel#removealpha removeAlpha}.
489
462
  *
490
463
  * @example
491
464
  * await sharp(rgbaInput)
@@ -510,8 +483,6 @@ function flatten (options) {
510
483
  *
511
484
  * Existing alpha channel values for non-white pixels remain unchanged.
512
485
  *
513
- * This feature is experimental and the API may change.
514
- *
515
486
  * @since 0.32.1
516
487
  *
517
488
  * @example
@@ -660,7 +631,7 @@ function normalize (options) {
660
631
 
661
632
  /**
662
633
  * Perform contrast limiting adaptive histogram equalization
663
- * {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE|CLAHE}.
634
+ * {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE CLAHE}.
664
635
  *
665
636
  * This will, in general, enhance the clarity of the image by bringing out darker details.
666
637
  *
@@ -742,9 +713,7 @@ function convolve (kernel) {
742
713
  }
743
714
  // Default scale is sum of kernel values
744
715
  if (!is.integer(kernel.scale)) {
745
- kernel.scale = kernel.kernel.reduce(function (a, b) {
746
- return a + b;
747
- }, 0);
716
+ kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);
748
717
  }
749
718
  // Clip scale to a minimum value of 1
750
719
  if (kernel.scale < 1) {
@@ -989,7 +958,7 @@ function modulate (options) {
989
958
  * @module Sharp
990
959
  * @private
991
960
  */
992
- module.exports = function (Sharp) {
961
+ module.exports = (Sharp) => {
993
962
  Object.assign(Sharp.prototype, {
994
963
  autoOrient,
995
964
  rotate,
package/lib/output.js CHANGED
@@ -43,7 +43,7 @@ const bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math
43
43
  * Note that raw pixel data is only supported for buffer output.
44
44
  *
45
45
  * By default all metadata will be removed, which includes EXIF-based orientation.
46
- * See {@link #withmetadata|withMetadata} for control over this.
46
+ * See {@link #withmetadata withMetadata} for control over this.
47
47
  *
48
48
  * The caller is responsible for ensuring directory structures and permissions exist.
49
49
  *
@@ -76,7 +76,7 @@ function toFile (fileOut, callback) {
76
76
  err = new Error('Missing output file path');
77
77
  } else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {
78
78
  err = new Error('Cannot use same file for input and output');
79
- } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
79
+ } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2.output.file) {
80
80
  err = errJp2Save();
81
81
  }
82
82
  if (err) {
@@ -97,12 +97,12 @@ function toFile (fileOut, callback) {
97
97
  * Write output to a Buffer.
98
98
  * JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
99
99
  *
100
- * Use {@link #toformat|toFormat} or one of the format-specific functions such as {@link jpeg}, {@link png} etc. to set the output format.
100
+ * Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.
101
101
  *
102
102
  * If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
103
103
  *
104
104
  * By default all metadata will be removed, which includes EXIF-based orientation.
105
- * See {@link #withmetadata|withMetadata} for control over this.
105
+ * See {@link #withmetadata withMetadata} for control over this.
106
106
  *
107
107
  * `callback`, if present, gets three arguments `(err, data, info)` where:
108
108
  * - `err` is an error, if any.
@@ -164,6 +164,41 @@ function toBuffer (options, callback) {
164
164
  return this._pipeline(is.fn(options) ? options : callback, stack);
165
165
  }
166
166
 
167
+ /**
168
+ * Write output to a `Uint8Array` backed by a transferable `ArrayBuffer`.
169
+ * JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
170
+ *
171
+ * Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.
172
+ *
173
+ * If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
174
+ *
175
+ * By default all metadata will be removed, which includes EXIF-based orientation.
176
+ * See {@link #keepexif keepExif} and similar methods for control over this.
177
+ *
178
+ * Resolves with an `Object` containing:
179
+ * - `data` is the output image as a `Uint8Array` backed by a transferable `ArrayBuffer`.
180
+ * - `info` contains properties relating to the output image such as `width` and `height`.
181
+ *
182
+ * @since v0.35.0
183
+ *
184
+ * @example
185
+ * const { data, info } = await sharp(input).toUint8Array();
186
+ *
187
+ * @example
188
+ * const { data } = await sharp(input)
189
+ * .avif()
190
+ * .toUint8Array();
191
+ * const base64String = data.toBase64();
192
+ *
193
+ * @returns {Promise<{ data: Uint8Array, info: Object }>}
194
+ */
195
+ function toUint8Array () {
196
+ this.options.resolveWithObject = true;
197
+ this.options.typedArrayOut = true;
198
+ const stack = Error();
199
+ return this._pipeline(null, stack);
200
+ }
201
+
167
202
  /**
168
203
  * Keep all EXIF metadata from the input image in the output image.
169
204
  *
@@ -256,7 +291,7 @@ function withExifMerge (exif) {
256
291
  /**
257
292
  * Keep ICC profile from the input image in the output image.
258
293
  *
259
- * Where necessary, will attempt to convert the output colour space to match the profile.
294
+ * When input and output colour spaces differ, use with {@link /api-colour/#tocolourspace toColourspace} and optionally {@link /api-colour/#pipelinecolourspace pipelineColourspace}.
260
295
  *
261
296
  * @since 0.33.0
262
297
  *
@@ -265,6 +300,13 @@ function withExifMerge (exif) {
265
300
  * .keepIccProfile()
266
301
  * .toBuffer();
267
302
  *
303
+ * @example
304
+ * const cmykOutputWithIccProfile = await sharp(cmykInputWithIccProfile)
305
+ * .pipelineColourspace('cmyk')
306
+ * .toColourspace('cmyk')
307
+ * .keepIccProfile()
308
+ * .toBuffer();
309
+ *
268
310
  * @returns {Sharp}
269
311
  */
270
312
  function keepIccProfile () {
@@ -312,6 +354,30 @@ function withIccProfile (icc, options) {
312
354
  return this;
313
355
  }
314
356
 
357
+ /**
358
+ * If the input contains gain map metadata, use it to convert the main image to HDR (High Dynamic Range) before further processing.
359
+ * The input gain map is discarded.
360
+ *
361
+ * If the output is JPEG, generate and attach a new ISO 21496-1 gain map.
362
+ * JPEG output options other than `quality` are ignored.
363
+ *
364
+ * This feature is experimental and the API may change.
365
+ *
366
+ * @since 0.35.0
367
+ *
368
+ * @example
369
+ * const outputWithGainMap = await sharp(inputWithGainMap)
370
+ * .withGainMap()
371
+ * .toBuffer();
372
+ *
373
+ * @returns {Sharp}
374
+ */
375
+ function withGainMap() {
376
+ this.options.withGainMap = true;
377
+ this.options.colourspace = 'scrgb';
378
+ return this;
379
+ }
380
+
315
381
  /**
316
382
  * Keep XMP metadata from the input image in the output image.
317
383
  *
@@ -565,7 +631,7 @@ function jpeg (options) {
565
631
  * Set `palette` to `true` for slower, indexed PNG output.
566
632
  *
567
633
  * For 16 bits per pixel output, convert to `rgb16` via
568
- * {@link /api-colour#tocolourspace|toColourspace}.
634
+ * {@link /api-colour/#tocolourspace toColourspace}.
569
635
  *
570
636
  * @example
571
637
  * // Convert any input to full colour PNG output
@@ -683,6 +749,7 @@ function png (options) {
683
749
  * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
684
750
  * @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)
685
751
  * @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)
752
+ * @param {boolean} [options.exact=false] - preserve the colour data in transparent pixels
686
753
  * @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
687
754
  * @returns {Sharp}
688
755
  * @throws {Error} Invalid options
@@ -735,6 +802,9 @@ function webp (options) {
735
802
  if (is.defined(options.mixed)) {
736
803
  this._setBooleanOption('webpMixed', options.mixed);
737
804
  }
805
+ if (is.defined(options.exact)) {
806
+ this._setBooleanOption('webpExact', options.exact);
807
+ }
738
808
  }
739
809
  trySetAnimationOptions(options, this.options);
740
810
  return this._updateFormatOut('webp', options);
@@ -850,7 +920,7 @@ function gif (options) {
850
920
  *
851
921
  * Requires libvips compiled with support for OpenJPEG.
852
922
  * The prebuilt binaries do not include this - see
853
- * {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
923
+ * {@link /install#custom-libvips installing a custom libvips}.
854
924
  *
855
925
  * @example
856
926
  * // Convert any input to lossless JP2 output
@@ -880,7 +950,7 @@ function gif (options) {
880
950
  */
881
951
  function jp2 (options) {
882
952
  /* node:coverage ignore next 41 */
883
- if (!this.constructor.format.jp2k.output.buffer) {
953
+ if (!this.constructor.format.jp2.output.buffer) {
884
954
  throw errJp2Save();
885
955
  }
886
956
  if (is.object(options)) {
@@ -959,7 +1029,7 @@ function trySetAnimationOptions (source, target) {
959
1029
  /**
960
1030
  * Use these TIFF options for output image.
961
1031
  *
962
- * The `density` can be set in pixels/inch via {@link #withmetadata|withMetadata}
1032
+ * The `density` can be set in pixels/inch via {@link #withmetadata withMetadata}
963
1033
  * instead of providing `xres` and `yres` in pixels/mm.
964
1034
  *
965
1035
  * @example
@@ -985,7 +1055,7 @@ function trySetAnimationOptions (source, target) {
985
1055
  * @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm
986
1056
  * @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
987
1057
  * @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
988
- * @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
1058
+ * @param {number} [options.bitdepth=0] - reduce bitdepth to 1, 2 or 4 bit
989
1059
  * @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
990
1060
  * @returns {Sharp}
991
1061
  * @throws {Error} Invalid options
@@ -1000,10 +1070,10 @@ function tiff (options) {
1000
1070
  }
1001
1071
  }
1002
1072
  if (is.defined(options.bitdepth)) {
1003
- if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {
1073
+ if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4])) {
1004
1074
  this.options.tiffBitdepth = options.bitdepth;
1005
1075
  } else {
1006
- throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth);
1076
+ throw is.invalidParameterError('bitdepth', '1, 2 or 4', options.bitdepth);
1007
1077
  }
1008
1078
  }
1009
1079
  // tiling
@@ -1085,8 +1155,7 @@ function tiff (options) {
1085
1155
  * AVIF image sequences are not supported.
1086
1156
  * Prebuilt binaries support a bitdepth of 8 only.
1087
1157
  *
1088
- * This feature is experimental on the Windows ARM64 platform
1089
- * and requires a CPU with ARM64v8.4 or later.
1158
+ * When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
1090
1159
  *
1091
1160
  * @example
1092
1161
  * const data = await sharp(input)
@@ -1106,11 +1175,13 @@ function tiff (options) {
1106
1175
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1107
1176
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1108
1177
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1178
+ * @param {string} [options.tune='iq'] - tune output for a quality metric, one of 'iq' (default), 'ssim' (default when lossless) or 'psnr'
1109
1179
  * @returns {Sharp}
1110
1180
  * @throws {Error} Invalid options
1111
1181
  */
1112
1182
  function avif (options) {
1113
- return this.heif({ ...options, compression: 'av1' });
1183
+ const tune = is.object(options) && is.defined(options.tune) ? options.tune : 'iq';
1184
+ return this.heif({ ...options, compression: 'av1', tune });
1114
1185
  }
1115
1186
 
1116
1187
  /**
@@ -1133,6 +1204,7 @@ function avif (options) {
1133
1204
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1134
1205
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1135
1206
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1207
+ * @param {string} [options.tune='ssim'] - tune output for a quality metric, one of 'ssim' (default), 'psnr' or 'iq'
1136
1208
  * @returns {Sharp}
1137
1209
  * @throws {Error} Invalid options
1138
1210
  */
@@ -1181,6 +1253,17 @@ function heif (options) {
1181
1253
  throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);
1182
1254
  }
1183
1255
  }
1256
+ if (is.defined(options.tune)) {
1257
+ if (is.string(options.tune) && is.inArray(options.tune, ['iq', 'ssim', 'psnr'])) {
1258
+ if (this.options.heifLossless && options.tune === 'iq') {
1259
+ this.options.heifTune = 'ssim';
1260
+ } else {
1261
+ this.options.heifTune = options.tune;
1262
+ }
1263
+ } else {
1264
+ throw is.invalidParameterError('tune', 'one of: psnr, ssim, iq', options.tune);
1265
+ }
1266
+ }
1184
1267
  } else {
1185
1268
  throw is.invalidParameterError('options', 'Object', options);
1186
1269
  }
@@ -1194,7 +1277,7 @@ function heif (options) {
1194
1277
  *
1195
1278
  * Requires libvips compiled with support for libjxl.
1196
1279
  * The prebuilt binaries do not include this - see
1197
- * {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
1280
+ * {@link /install/#custom-libvips installing a custom libvips}.
1198
1281
  *
1199
1282
  * @since 0.31.3
1200
1283
  *
@@ -1623,16 +1706,18 @@ function _pipeline (callback, stack) {
1623
1706
  * @module Sharp
1624
1707
  * @private
1625
1708
  */
1626
- module.exports = function (Sharp) {
1709
+ module.exports = (Sharp) => {
1627
1710
  Object.assign(Sharp.prototype, {
1628
1711
  // Public
1629
1712
  toFile,
1630
1713
  toBuffer,
1714
+ toUint8Array,
1631
1715
  keepExif,
1632
1716
  withExif,
1633
1717
  withExifMerge,
1634
1718
  keepIccProfile,
1635
1719
  withIccProfile,
1720
+ withGainMap,
1636
1721
  keepXmp,
1637
1722
  withXmp,
1638
1723
  keepMetadata,
package/lib/resize.js CHANGED
@@ -540,10 +540,19 @@ function extract (options) {
540
540
  * })
541
541
  * .toBuffer();
542
542
  *
543
+ * @example
544
+ * // Trim image leaving (up to) a 10 pixel margin around the trimmed content.
545
+ * const output = await sharp(input)
546
+ * .trim({
547
+ * margin: 10
548
+ * })
549
+ * .toBuffer();
550
+ *
543
551
  * @param {Object} [options]
544
552
  * @param {string|Object} [options.background='top-left pixel'] - Background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to that of the top-left pixel.
545
553
  * @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.
546
554
  * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
555
+ * @param {number} [options.margin=0] - Leave a margin around trimmed content, value is in pixels.
547
556
  * @returns {Sharp}
548
557
  * @throws {Error} Invalid parameters
549
558
  */
@@ -564,6 +573,13 @@ function trim (options) {
564
573
  if (is.defined(options.lineArt)) {
565
574
  this._setBooleanOption('trimLineArt', options.lineArt);
566
575
  }
576
+ if (is.defined(options.margin)) {
577
+ if (is.integer(options.margin) && options.margin >= 0) {
578
+ this.options.trimMargin = options.margin;
579
+ } else {
580
+ throw is.invalidParameterError('margin', 'positive integer', options.margin);
581
+ }
582
+ }
567
583
  } else {
568
584
  throw is.invalidParameterError('trim', 'object', options);
569
585
  }
@@ -579,7 +595,7 @@ function trim (options) {
579
595
  * @module Sharp
580
596
  * @private
581
597
  */
582
- module.exports = function (Sharp) {
598
+ module.exports = (Sharp) => {
583
599
  Object.assign(Sharp.prototype, {
584
600
  resize,
585
601
  extend,
package/lib/sharp.js CHANGED
@@ -7,12 +7,13 @@
7
7
 
8
8
  const { familySync, versionSync } = require('detect-libc');
9
9
 
10
+ const { version } = require('../package.json');
10
11
  const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
11
12
  const runtimePlatform = runtimePlatformArch();
12
13
 
13
14
  const paths = [
14
- `../src/build/Release/sharp-${runtimePlatform}.node`,
15
- '../src/build/Release/sharp-wasm32.node',
15
+ `../src/build/Release/sharp-${runtimePlatform}-${version}.node`,
16
+ `../src/build/Release/sharp-wasm32-${version}.node`,
16
17
  `@revizly/sharp-${runtimePlatform}/sharp.node`,
17
18
  '@revizly/sharp-wasm32/sharp.node'
18
19
  ];
@@ -72,6 +73,7 @@ if (sharp) {
72
73
  } else {
73
74
  help.push(
74
75
  `- Manually install libvips >= ${minimumLibvipsVersion}`,
76
+ ' See https://sharp.pixelplumbing.com/install#building-from-source',
75
77
  '- Add experimental WebAssembly-based dependencies:',
76
78
  ' npm install --cpu=wasm32 sharp',
77
79
  ' npm install @revizly/sharp-wasm32'
package/lib/utility.js CHANGED
@@ -24,7 +24,7 @@ const format = sharp.format();
24
24
  format.heif.output.alias = ['avif', 'heic'];
25
25
  format.jpeg.output.alias = ['jpe', 'jpg'];
26
26
  format.tiff.output.alias = ['tif'];
27
- format.jp2k.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];
27
+ format.jp2.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];
28
28
 
29
29
  /**
30
30
  * An Object containing the available interpolators and their proper values
@@ -136,7 +136,7 @@ cache(true);
136
136
  * and these are independent of the value set here.
137
137
  *
138
138
  * :::note
139
- * Further {@link /performance|control over performance} is available.
139
+ * Further {@link /performance/ control over performance} is available.
140
140
  * :::
141
141
  *
142
142
  * @example
@@ -277,7 +277,7 @@ function unblock (options) {
277
277
  * @module Sharp
278
278
  * @private
279
279
  */
280
- module.exports = function (Sharp) {
280
+ module.exports = (Sharp) => {
281
281
  Sharp.cache = cache;
282
282
  Sharp.concurrency = concurrency;
283
283
  Sharp.counters = counters;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@revizly/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.34.5-revizly3",
4
+ "version": "0.35.0-revizly10",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -89,12 +89,12 @@
89
89
  "Lachlan Newman <lachnewman007@gmail.com>",
90
90
  "Dennis Beatty <dennis@dcbeatty.com>",
91
91
  "Ingvar Stepanyan <me@rreverser.com>",
92
- "Don Denton <don@happycollision.com>"
92
+ "Don Denton <don@happycollision.com>",
93
+ "Dmytro Tiapukhin <cool.gegeg@gmail.com>"
93
94
  ],
94
95
  "scripts": {
95
96
  "build": "node install/build.js",
96
- "install": "node install/check.js || npm run build",
97
- "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
97
+ "clean": "rm -rf src/build/ test/fixtures/output.*",
98
98
  "test": "npm run lint && npm run test-unit",
99
99
  "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
100
100
  "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
@@ -144,41 +144,34 @@
144
144
  "semver": "^7.7.3"
145
145
  },
146
146
  "optionalDependencies": {
147
- "@revizly/sharp-libvips-linux-arm64": "1.0.25",
148
- "@revizly/sharp-libvips-linux-x64": "1.0.25",
149
- "@revizly/sharp-linux-arm64": "0.34.5-revizly1",
150
- "@revizly/sharp-linux-x64": "0.34.5-revizly1"
147
+ "@revizly/sharp-libvips-linux-arm64": "1.0.26",
148
+ "@revizly/sharp-libvips-linux-x64": "1.0.26",
149
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly1",
150
+ "@revizly/sharp-linux-x64": "0.35.0-revizly1"
151
151
  },
152
152
  "devDependencies": {
153
- "@biomejs/biome": "^2.3.2",
153
+ "@biomejs/biome": "^2.3.10",
154
154
  "@cpplint/cli": "^0.1.0",
155
- "@emnapi/runtime": "^1.6.0",
156
- "@revizly/sharp-libvips-dev": "1.0.25",
155
+ "@emnapi/runtime": "^1.7.1",
156
+ "@revizly/sharp-libvips-dev": "1.0.26",
157
157
  "@types/node": "*",
158
- "emnapi": "^1.6.0",
159
- "exif-reader": "^2.0.2",
158
+ "emnapi": "^1.7.1",
159
+ "exif-reader": "^2.0.3",
160
160
  "extract-zip": "^2.0.1",
161
161
  "icc": "^3.0.0",
162
- "jsdoc-to-markdown": "^9.1.3",
163
162
  "node-addon-api": "^8.5.0",
164
- "node-gyp": "^11.5.0",
163
+ "node-gyp": "^12.1.0",
165
164
  "tar-fs": "^3.1.1",
166
165
  "tsd": "^0.33.0"
167
166
  },
168
167
  "license": "Apache-2.0",
169
168
  "engines": {
170
- "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
169
+ "node": ">=20.9.0"
171
170
  },
172
171
  "config": {
173
- "libvips": ">=8.17.3"
172
+ "libvips": ">=8.18.0"
174
173
  },
175
174
  "funding": {
176
175
  "url": "https://opencollective.com/libvips"
177
- },
178
- "cc": {
179
- "linelength": "120",
180
- "filter": [
181
- "build/include"
182
- ]
183
176
  }
184
177
  }
package/src/binding.gyp CHANGED
@@ -5,6 +5,7 @@
5
5
  'variables': {
6
6
  'vips_version': '<!(node -p "require(\'../lib/libvips\').minimumLibvipsVersion")',
7
7
  'platform_and_arch': '<!(node -p "require(\'../lib/libvips\').buildPlatformArch()")',
8
+ 'sharp_version': '<!(node -p "require(\'../package.json\').version")',
8
9
  'sharp_libvips_version': '<!(node -p "require(\'../package.json\').optionalDependencies[\'@revizly/sharp-libvips-<(platform_and_arch)\']")',
9
10
  'sharp_libvips_yarn_locator': '<!(node -p "require(\'../lib/libvips\').yarnLocator()")',
10
11
  'sharp_libvips_include_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsIncludeDir()")',
@@ -20,6 +21,7 @@
20
21
  'defines': [
21
22
  '_VIPS_PUBLIC=__declspec(dllexport)',
22
23
  '_ALLOW_KEYWORD_MACROS',
24
+ '_HAS_EXCEPTIONS=1',
23
25
  'G_DISABLE_ASSERT',
24
26
  'G_DISABLE_CAST_CHECKS',
25
27
  'G_DISABLE_CHECKS'
@@ -81,7 +83,7 @@
81
83
  }]
82
84
  ]
83
85
  }, {
84
- 'target_name': 'sharp-<(platform_and_arch)',
86
+ 'target_name': 'sharp-<(platform_and_arch)-<(sharp_version)',
85
87
  'defines': [
86
88
  'G_DISABLE_ASSERT',
87
89
  'G_DISABLE_CAST_CHECKS',
@@ -120,7 +122,7 @@
120
122
  'conditions': [
121
123
  ['use_global_libvips == "true"', {
122
124
  # Use pkg-config for include and lib
123
- 'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
125
+ 'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s/-I//g)'],
124
126
  'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
125
127
  'defines': [
126
128
  'SHARP_USE_GLOBAL_LIBVIPS'
@@ -147,7 +149,8 @@
147
149
  ['OS == "win"', {
148
150
  'defines': [
149
151
  '_ALLOW_KEYWORD_MACROS',
150
- '_FILE_OFFSET_BITS=64'
152
+ '_FILE_OFFSET_BITS=64',
153
+ '_HAS_EXCEPTIONS=1'
151
154
  ],
152
155
  'link_settings': {
153
156
  'libraries': [
@@ -282,7 +285,7 @@
282
285
  'target_name': 'copy-dll',
283
286
  'type': 'none',
284
287
  'dependencies': [
285
- 'sharp-<(platform_and_arch)'
288
+ 'sharp-<(platform_and_arch)-<(sharp_version)'
286
289
  ],
287
290
  'conditions': [
288
291
  ['OS == "win"', {