sharp 0.34.5 → 0.35.0-rc.2
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 +7 -17
- package/install/build.js +2 -2
- package/lib/constructor.js +8 -2
- package/lib/index.d.ts +60 -62
- package/lib/input.js +4 -10
- package/lib/libvips.js +27 -19
- package/lib/operation.js +4 -33
- package/lib/output.js +141 -8
- package/lib/resize.js +16 -0
- package/lib/sharp.js +62 -20
- package/lib/utility.js +1 -1
- package/package.json +46 -45
- package/src/binding.gyp +11 -6
- package/src/common.cc +64 -14
- package/src/common.h +21 -4
- package/src/metadata.cc +66 -8
- package/src/metadata.h +6 -1
- package/src/operations.cc +25 -8
- package/src/operations.h +1 -1
- package/src/pipeline.cc +186 -51
- package/src/pipeline.h +13 -1
- package/src/stats.cc +6 -6
- package/src/utilities.cc +4 -3
- package/install/check.js +0 -14
package/lib/operation.js
CHANGED
|
@@ -259,45 +259,18 @@ function affine (matrix, options) {
|
|
|
259
259
|
* })
|
|
260
260
|
* .toBuffer();
|
|
261
261
|
*
|
|
262
|
-
* @param {Object
|
|
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
|
|
275
|
-
if (
|
|
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
|
-
|
|
315
|
+
this.options.sharpenSigma = -1;
|
|
343
316
|
}
|
|
344
317
|
return this;
|
|
345
318
|
}
|
|
@@ -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
|
package/lib/output.js
CHANGED
|
@@ -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.
|
|
79
|
+
} else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2.output.file) {
|
|
80
80
|
err = errJp2Save();
|
|
81
81
|
}
|
|
82
82
|
if (err) {
|
|
@@ -164,6 +164,64 @@ 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
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Set output density (DPI) in EXIF metadata.
|
|
204
|
+
*
|
|
205
|
+
* @since 0.35.0
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* const data = await sharp(input)
|
|
209
|
+
* .withDensity(96)
|
|
210
|
+
* .toBuffer();
|
|
211
|
+
*
|
|
212
|
+
* @param {number} density Number of pixels per inch (DPI).
|
|
213
|
+
* @returns {Sharp}
|
|
214
|
+
* @throws {Error} Invalid parameters
|
|
215
|
+
*/
|
|
216
|
+
function withDensity (density) {
|
|
217
|
+
if (is.number(density) && density > 0) {
|
|
218
|
+
this.options.withMetadataDensity = density;
|
|
219
|
+
} else {
|
|
220
|
+
throw is.invalidParameterError('density', 'positive number', density);
|
|
221
|
+
}
|
|
222
|
+
return this.keepExif();
|
|
223
|
+
}
|
|
224
|
+
|
|
167
225
|
/**
|
|
168
226
|
* Keep all EXIF metadata from the input image in the output image.
|
|
169
227
|
*
|
|
@@ -319,6 +377,60 @@ function withIccProfile (icc, options) {
|
|
|
319
377
|
return this;
|
|
320
378
|
}
|
|
321
379
|
|
|
380
|
+
/**
|
|
381
|
+
* If the input contains gain map metadata, attempt to process the image and gain map separately,
|
|
382
|
+
* recombining them into a single output image.
|
|
383
|
+
*
|
|
384
|
+
* This approach is faster and should produce better results than {@link #withgainmap withGainMap},
|
|
385
|
+
* however not all operations are supported.
|
|
386
|
+
*
|
|
387
|
+
* Only JPEG input and output are supported.
|
|
388
|
+
* JPEG output options other than `quality` are ignored.
|
|
389
|
+
*
|
|
390
|
+
* This feature is experimental and the API may change.
|
|
391
|
+
*
|
|
392
|
+
* @since 0.35.0
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* const outputWithResizedGainMap = await sharp(inputWithGainMap)
|
|
396
|
+
* .keepGainMap()
|
|
397
|
+
* .resize({ width: 64 })
|
|
398
|
+
* .toBuffer();
|
|
399
|
+
*
|
|
400
|
+
* @returns {Sharp}
|
|
401
|
+
*/
|
|
402
|
+
function keepGainMap() {
|
|
403
|
+
this.options.keepGainMap = true;
|
|
404
|
+
this.options.withGainMap = false;
|
|
405
|
+
this.options.keepMetadata |= 0b100000;
|
|
406
|
+
return this;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* If the input contains gain map metadata, use it to convert the main image to HDR (High Dynamic Range) before further processing.
|
|
411
|
+
* The input gain map is discarded.
|
|
412
|
+
*
|
|
413
|
+
* If the output is JPEG, generate and attach a new ISO 21496-1 gain map.
|
|
414
|
+
* JPEG output options other than `quality` are ignored.
|
|
415
|
+
*
|
|
416
|
+
* This feature is experimental and the API may change.
|
|
417
|
+
*
|
|
418
|
+
* @since 0.35.0
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* const outputWithRegeneratedGainMap = await sharp(inputWithGainMap)
|
|
422
|
+
* .withGainMap()
|
|
423
|
+
* .toBuffer();
|
|
424
|
+
*
|
|
425
|
+
* @returns {Sharp}
|
|
426
|
+
*/
|
|
427
|
+
function withGainMap() {
|
|
428
|
+
this.options.withGainMap = true;
|
|
429
|
+
this.options.keepGainMap = false;
|
|
430
|
+
this.options.colourspace = 'scrgb';
|
|
431
|
+
return this;
|
|
432
|
+
}
|
|
433
|
+
|
|
322
434
|
/**
|
|
323
435
|
* Keep XMP metadata from the input image in the output image.
|
|
324
436
|
*
|
|
@@ -690,6 +802,7 @@ function png (options) {
|
|
|
690
802
|
* @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
|
|
691
803
|
* @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)
|
|
692
804
|
* @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)
|
|
805
|
+
* @param {boolean} [options.exact=false] - preserve the colour data in transparent pixels
|
|
693
806
|
* @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
|
|
694
807
|
* @returns {Sharp}
|
|
695
808
|
* @throws {Error} Invalid options
|
|
@@ -742,6 +855,9 @@ function webp (options) {
|
|
|
742
855
|
if (is.defined(options.mixed)) {
|
|
743
856
|
this._setBooleanOption('webpMixed', options.mixed);
|
|
744
857
|
}
|
|
858
|
+
if (is.defined(options.exact)) {
|
|
859
|
+
this._setBooleanOption('webpExact', options.exact);
|
|
860
|
+
}
|
|
745
861
|
}
|
|
746
862
|
trySetAnimationOptions(options, this.options);
|
|
747
863
|
return this._updateFormatOut('webp', options);
|
|
@@ -887,7 +1003,7 @@ function gif (options) {
|
|
|
887
1003
|
*/
|
|
888
1004
|
function jp2 (options) {
|
|
889
1005
|
/* node:coverage ignore next 41 */
|
|
890
|
-
if (!this.constructor.format.
|
|
1006
|
+
if (!this.constructor.format.jp2.output.buffer) {
|
|
891
1007
|
throw errJp2Save();
|
|
892
1008
|
}
|
|
893
1009
|
if (is.object(options)) {
|
|
@@ -992,7 +1108,7 @@ function trySetAnimationOptions (source, target) {
|
|
|
992
1108
|
* @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm
|
|
993
1109
|
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
|
|
994
1110
|
* @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
|
|
995
|
-
* @param {number} [options.bitdepth=
|
|
1111
|
+
* @param {number} [options.bitdepth=0] - reduce bitdepth to 1, 2 or 4 bit
|
|
996
1112
|
* @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
|
|
997
1113
|
* @returns {Sharp}
|
|
998
1114
|
* @throws {Error} Invalid options
|
|
@@ -1007,10 +1123,10 @@ function tiff (options) {
|
|
|
1007
1123
|
}
|
|
1008
1124
|
}
|
|
1009
1125
|
if (is.defined(options.bitdepth)) {
|
|
1010
|
-
if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4
|
|
1126
|
+
if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4])) {
|
|
1011
1127
|
this.options.tiffBitdepth = options.bitdepth;
|
|
1012
1128
|
} else {
|
|
1013
|
-
throw is.invalidParameterError('bitdepth', '1, 2
|
|
1129
|
+
throw is.invalidParameterError('bitdepth', '1, 2 or 4', options.bitdepth);
|
|
1014
1130
|
}
|
|
1015
1131
|
}
|
|
1016
1132
|
// tiling
|
|
@@ -1092,8 +1208,7 @@ function tiff (options) {
|
|
|
1092
1208
|
* AVIF image sequences are not supported.
|
|
1093
1209
|
* Prebuilt binaries support a bitdepth of 8 only.
|
|
1094
1210
|
*
|
|
1095
|
-
*
|
|
1096
|
-
* and requires a CPU with ARM64v8.4 or later.
|
|
1211
|
+
* When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
|
|
1097
1212
|
*
|
|
1098
1213
|
* @example
|
|
1099
1214
|
* const data = await sharp(input)
|
|
@@ -1113,11 +1228,13 @@ function tiff (options) {
|
|
|
1113
1228
|
* @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
|
|
1114
1229
|
* @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
|
|
1115
1230
|
* @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
|
|
1231
|
+
* @param {string} [options.tune='iq'] - tune output for a quality metric, one of 'iq' (default), 'ssim' (default when lossless) or 'psnr'
|
|
1116
1232
|
* @returns {Sharp}
|
|
1117
1233
|
* @throws {Error} Invalid options
|
|
1118
1234
|
*/
|
|
1119
1235
|
function avif (options) {
|
|
1120
|
-
|
|
1236
|
+
const tune = is.object(options) && is.defined(options.tune) ? options.tune : 'iq';
|
|
1237
|
+
return this.heif({ ...options, compression: 'av1', tune });
|
|
1121
1238
|
}
|
|
1122
1239
|
|
|
1123
1240
|
/**
|
|
@@ -1140,6 +1257,7 @@ function avif (options) {
|
|
|
1140
1257
|
* @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
|
|
1141
1258
|
* @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
|
|
1142
1259
|
* @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
|
|
1260
|
+
* @param {string} [options.tune='ssim'] - tune output for a quality metric, one of 'ssim' (default), 'psnr' or 'iq'
|
|
1143
1261
|
* @returns {Sharp}
|
|
1144
1262
|
* @throws {Error} Invalid options
|
|
1145
1263
|
*/
|
|
@@ -1188,6 +1306,17 @@ function heif (options) {
|
|
|
1188
1306
|
throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);
|
|
1189
1307
|
}
|
|
1190
1308
|
}
|
|
1309
|
+
if (is.defined(options.tune)) {
|
|
1310
|
+
if (is.string(options.tune) && is.inArray(options.tune, ['iq', 'ssim', 'psnr'])) {
|
|
1311
|
+
if (this.options.heifLossless && options.tune === 'iq') {
|
|
1312
|
+
this.options.heifTune = 'ssim';
|
|
1313
|
+
} else {
|
|
1314
|
+
this.options.heifTune = options.tune;
|
|
1315
|
+
}
|
|
1316
|
+
} else {
|
|
1317
|
+
throw is.invalidParameterError('tune', 'one of: psnr, ssim, iq', options.tune);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1191
1320
|
} else {
|
|
1192
1321
|
throw is.invalidParameterError('options', 'Object', options);
|
|
1193
1322
|
}
|
|
@@ -1635,11 +1764,15 @@ module.exports = (Sharp) => {
|
|
|
1635
1764
|
// Public
|
|
1636
1765
|
toFile,
|
|
1637
1766
|
toBuffer,
|
|
1767
|
+
toUint8Array,
|
|
1768
|
+
withDensity,
|
|
1638
1769
|
keepExif,
|
|
1639
1770
|
withExif,
|
|
1640
1771
|
withExifMerge,
|
|
1641
1772
|
keepIccProfile,
|
|
1642
1773
|
withIccProfile,
|
|
1774
|
+
keepGainMap,
|
|
1775
|
+
withGainMap,
|
|
1643
1776
|
keepXmp,
|
|
1644
1777
|
withXmp,
|
|
1645
1778
|
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
|
}
|
package/lib/sharp.js
CHANGED
|
@@ -7,34 +7,76 @@
|
|
|
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
|
-
const paths = [
|
|
14
|
-
`../src/build/Release/sharp-${runtimePlatform}.node`,
|
|
15
|
-
'../src/build/Release/sharp-wasm32.node',
|
|
16
|
-
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
17
|
-
'@img/sharp-wasm32/sharp.node'
|
|
18
|
-
];
|
|
19
|
-
|
|
20
14
|
/* node:coverage disable */
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
const prebuiltBinaryForRuntime = () => {
|
|
17
|
+
switch (runtimePlatform) {
|
|
18
|
+
case 'darwin-arm64':
|
|
19
|
+
return require('@img/sharp-darwin-arm64/sharp.node');
|
|
20
|
+
case 'darwin-x64':
|
|
21
|
+
return require('@img/sharp-darwin-x64/sharp.node');
|
|
22
|
+
case 'linux-arm':
|
|
23
|
+
return require('@img/sharp-linux-arm/sharp.node');
|
|
24
|
+
case 'linux-arm64':
|
|
25
|
+
return require('@img/sharp-linux-arm64/sharp.node');
|
|
26
|
+
case 'linux-ppc64':
|
|
27
|
+
return require('@img/sharp-linux-ppc64/sharp.node');
|
|
28
|
+
case 'linux-riscv64':
|
|
29
|
+
return require('@img/sharp-linux-riscv64/sharp.node');
|
|
30
|
+
case 'linux-s390x':
|
|
31
|
+
return require('@img/sharp-linux-s390x/sharp.node');
|
|
32
|
+
case 'linux-x64':
|
|
33
|
+
return require('@img/sharp-linux-x64/sharp.node');
|
|
34
|
+
case 'linuxmusl-arm64':
|
|
35
|
+
return require('@img/sharp-linuxmusl-arm64/sharp.node') ;
|
|
36
|
+
case 'linuxmusl-x64':
|
|
37
|
+
return require('@img/sharp-linuxmusl-x64/sharp.node');
|
|
38
|
+
case 'win32-arm64':
|
|
39
|
+
return require('@img/sharp-win32-arm64/sharp.node');
|
|
40
|
+
case 'win32-ia32':
|
|
41
|
+
return require('@img/sharp-win32-ia32/sharp.node');
|
|
42
|
+
case 'win32-x64':
|
|
43
|
+
return require('@img/sharp-win32-x64/sharp.node');
|
|
44
|
+
case 'freebsd-arm64':
|
|
45
|
+
case 'freebsd-x64':
|
|
46
|
+
return require('@img/sharp-freebsd-wasm32/sharp.node');
|
|
47
|
+
case 'linux-wasm32':
|
|
48
|
+
return require('@img/sharp-webcontainers-wasm32/sharp.node');
|
|
49
|
+
default:
|
|
50
|
+
return require('@img/sharp-wasm32/sharp.node');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let sharp;
|
|
23
55
|
const errors = [];
|
|
24
|
-
|
|
56
|
+
try {
|
|
57
|
+
sharp = require(`../src/build/Release/sharp-${runtimePlatform}-${version}.node`);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
errors.push(err);
|
|
60
|
+
}
|
|
61
|
+
if (!sharp) {
|
|
25
62
|
try {
|
|
26
|
-
sharp = require(
|
|
27
|
-
break;
|
|
63
|
+
sharp = require(`../src/build/Release/sharp-wasm32-${version}.node`);
|
|
28
64
|
} catch (err) {
|
|
29
65
|
errors.push(err);
|
|
30
66
|
}
|
|
31
67
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
if (!sharp) {
|
|
69
|
+
try {
|
|
70
|
+
sharp = prebuiltBinaryForRuntime();
|
|
71
|
+
if (['linux-x64', 'linuxmusl-x64'].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
|
|
72
|
+
const err = new Error('Prebuilt binaries for Linux x64 require v2 microarchitecture');
|
|
73
|
+
err.code = 'Unsupported CPU';
|
|
74
|
+
errors.push(err);
|
|
75
|
+
sharp = null;
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
errors.push(err);
|
|
79
|
+
}
|
|
38
80
|
}
|
|
39
81
|
|
|
40
82
|
if (sharp) {
|
|
@@ -72,9 +114,9 @@ if (sharp) {
|
|
|
72
114
|
} else {
|
|
73
115
|
help.push(
|
|
74
116
|
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
' npm install @img/sharp-wasm32'
|
|
117
|
+
' See https://sharp.pixelplumbing.com/install#building-from-source',
|
|
118
|
+
'- Add WebAssembly-based dependencies:',
|
|
119
|
+
' npm install sharp @img/sharp-wasm32'
|
|
78
120
|
);
|
|
79
121
|
}
|
|
80
122
|
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
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.
|
|
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
|
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.
|
|
4
|
+
"version": "0.35.0-rc.2",
|
|
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
|
-
"
|
|
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",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"test-leak": "./test/leak/leak.sh",
|
|
104
104
|
"test-unit": "node --experimental-test-coverage test/unit.mjs",
|
|
105
105
|
"package-from-local-build": "node npm/from-local-build.js",
|
|
106
|
+
"package-wasm-wrappers": "node npm/wasm-wrappers.js",
|
|
106
107
|
"package-release-notes": "node npm/release-notes.js",
|
|
107
108
|
"docs-build": "node docs/build.mjs",
|
|
108
109
|
"docs-serve": "cd docs && npm start",
|
|
@@ -139,62 +140,62 @@
|
|
|
139
140
|
"vips"
|
|
140
141
|
],
|
|
141
142
|
"dependencies": {
|
|
142
|
-
"@img/colour": "^1.
|
|
143
|
+
"@img/colour": "^1.1.0",
|
|
143
144
|
"detect-libc": "^2.1.2",
|
|
144
|
-
"semver": "^7.7.
|
|
145
|
+
"semver": "^7.7.4"
|
|
145
146
|
},
|
|
146
147
|
"optionalDependencies": {
|
|
147
|
-
"@img/sharp-darwin-arm64": "0.
|
|
148
|
-
"@img/sharp-darwin-x64": "0.
|
|
149
|
-
"@img/sharp-
|
|
150
|
-
"@img/sharp-libvips-darwin-
|
|
151
|
-
"@img/sharp-libvips-
|
|
152
|
-
"@img/sharp-libvips-linux-
|
|
153
|
-
"@img/sharp-libvips-linux-
|
|
154
|
-
"@img/sharp-libvips-linux-
|
|
155
|
-
"@img/sharp-libvips-linux-
|
|
156
|
-
"@img/sharp-libvips-linux-
|
|
157
|
-
"@img/sharp-libvips-
|
|
158
|
-
"@img/sharp-libvips-linuxmusl-
|
|
159
|
-
"@img/sharp-
|
|
160
|
-
"@img/sharp-linux-
|
|
161
|
-
"@img/sharp-linux-
|
|
162
|
-
"@img/sharp-linux-
|
|
163
|
-
"@img/sharp-linux-
|
|
164
|
-
"@img/sharp-linux-
|
|
165
|
-
"@img/sharp-
|
|
166
|
-
"@img/sharp-linuxmusl-
|
|
167
|
-
"@img/sharp-
|
|
168
|
-
"@img/sharp-
|
|
169
|
-
"@img/sharp-win32-
|
|
170
|
-
"@img/sharp-win32-
|
|
148
|
+
"@img/sharp-darwin-arm64": "0.35.0-rc.2",
|
|
149
|
+
"@img/sharp-darwin-x64": "0.35.0-rc.2",
|
|
150
|
+
"@img/sharp-freebsd-wasm32": "0.35.0-rc.2",
|
|
151
|
+
"@img/sharp-libvips-darwin-arm64": "1.3.0-rc.4",
|
|
152
|
+
"@img/sharp-libvips-darwin-x64": "1.3.0-rc.4",
|
|
153
|
+
"@img/sharp-libvips-linux-arm": "1.3.0-rc.4",
|
|
154
|
+
"@img/sharp-libvips-linux-arm64": "1.3.0-rc.4",
|
|
155
|
+
"@img/sharp-libvips-linux-ppc64": "1.3.0-rc.4",
|
|
156
|
+
"@img/sharp-libvips-linux-riscv64": "1.3.0-rc.4",
|
|
157
|
+
"@img/sharp-libvips-linux-s390x": "1.3.0-rc.4",
|
|
158
|
+
"@img/sharp-libvips-linux-x64": "1.3.0-rc.4",
|
|
159
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.3.0-rc.4",
|
|
160
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.3.0-rc.4",
|
|
161
|
+
"@img/sharp-linux-arm": "0.35.0-rc.2",
|
|
162
|
+
"@img/sharp-linux-arm64": "0.35.0-rc.2",
|
|
163
|
+
"@img/sharp-linux-ppc64": "0.35.0-rc.2",
|
|
164
|
+
"@img/sharp-linux-riscv64": "0.35.0-rc.2",
|
|
165
|
+
"@img/sharp-linux-s390x": "0.35.0-rc.2",
|
|
166
|
+
"@img/sharp-linux-x64": "0.35.0-rc.2",
|
|
167
|
+
"@img/sharp-linuxmusl-arm64": "0.35.0-rc.2",
|
|
168
|
+
"@img/sharp-linuxmusl-x64": "0.35.0-rc.2",
|
|
169
|
+
"@img/sharp-webcontainers-wasm32": "0.35.0-rc.2",
|
|
170
|
+
"@img/sharp-win32-arm64": "0.35.0-rc.2",
|
|
171
|
+
"@img/sharp-win32-ia32": "0.35.0-rc.2",
|
|
172
|
+
"@img/sharp-win32-x64": "0.35.0-rc.2"
|
|
171
173
|
},
|
|
172
174
|
"devDependencies": {
|
|
173
|
-
"@biomejs/biome": "^2.
|
|
175
|
+
"@biomejs/biome": "^2.4.10",
|
|
174
176
|
"@cpplint/cli": "^0.1.0",
|
|
175
|
-
"@emnapi/runtime": "^1.
|
|
176
|
-
"@img/sharp-libvips-dev": "1.
|
|
177
|
-
"@img/sharp-libvips-dev-wasm32": "1.
|
|
178
|
-
"@img/sharp-libvips-win32-arm64": "1.
|
|
179
|
-
"@img/sharp-libvips-win32-ia32": "1.
|
|
180
|
-
"@img/sharp-libvips-win32-x64": "1.
|
|
177
|
+
"@emnapi/runtime": "^1.9.2",
|
|
178
|
+
"@img/sharp-libvips-dev": "1.3.0-rc.4",
|
|
179
|
+
"@img/sharp-libvips-dev-wasm32": "1.3.0-rc.4",
|
|
180
|
+
"@img/sharp-libvips-win32-arm64": "1.3.0-rc.4",
|
|
181
|
+
"@img/sharp-libvips-win32-ia32": "1.3.0-rc.4",
|
|
182
|
+
"@img/sharp-libvips-win32-x64": "1.3.0-rc.4",
|
|
181
183
|
"@types/node": "*",
|
|
182
|
-
"emnapi": "^1.
|
|
183
|
-
"exif-reader": "^2.0.
|
|
184
|
+
"emnapi": "^1.9.2",
|
|
185
|
+
"exif-reader": "^2.0.3",
|
|
184
186
|
"extract-zip": "^2.0.1",
|
|
185
187
|
"icc": "^3.0.0",
|
|
186
|
-
"
|
|
187
|
-
"node-
|
|
188
|
-
"
|
|
189
|
-
"tar-fs": "^3.1.1",
|
|
188
|
+
"node-addon-api": "^8.7.0",
|
|
189
|
+
"node-gyp": "^12.2.0",
|
|
190
|
+
"tar-fs": "^3.1.2",
|
|
190
191
|
"tsd": "^0.33.0"
|
|
191
192
|
},
|
|
192
193
|
"license": "Apache-2.0",
|
|
193
194
|
"engines": {
|
|
194
|
-
"node": "
|
|
195
|
+
"node": ">=20.9.0"
|
|
195
196
|
},
|
|
196
197
|
"config": {
|
|
197
|
-
"libvips": ">=8.
|
|
198
|
+
"libvips": ">=8.18.2"
|
|
198
199
|
},
|
|
199
200
|
"funding": {
|
|
200
201
|
"url": "https://opencollective.com/libvips"
|