sharp 0.35.2 → 0.35.3-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/dist/colour.cjs +10 -6
- package/dist/colour.mjs +10 -6
- package/dist/index.d.cts +22 -18
- package/dist/index.d.mts +22 -18
- package/dist/input.cjs +8 -8
- package/dist/input.mjs +8 -8
- package/dist/is.cjs +1 -1
- package/dist/is.mjs +1 -1
- package/dist/operation.cjs +19 -12
- package/dist/operation.mjs +19 -12
- package/dist/output.cjs +20 -24
- package/dist/output.mjs +20 -24
- package/dist/resize.cjs +30 -26
- package/dist/resize.mjs +30 -26
- package/dist/sharp.cjs +6 -0
- package/dist/sharp.mjs +6 -0
- package/dist/utility.cjs +7 -1
- package/dist/utility.mjs +7 -1
- package/lib/index.d.ts +22 -18
- package/package.json +40 -35
- package/src/pipeline.cc +29 -30
- package/src/pipeline.h +2 -0
- package/src/utilities.cc +3 -3
package/dist/output.mjs
CHANGED
|
@@ -113,24 +113,20 @@ function toFile (fileOut, callback) {
|
|
|
113
113
|
* Animated output will also contain `pageHeight` and `pages`.
|
|
114
114
|
* May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.
|
|
115
115
|
*
|
|
116
|
-
*
|
|
116
|
+
* The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.
|
|
117
|
+
* Use {@link #touint8array toUint8Array} for a guaranteed transferable `ArrayBuffer`.
|
|
117
118
|
*
|
|
118
|
-
*
|
|
119
|
-
* sharp(input)
|
|
120
|
-
* .toBuffer((err, data, info) => { ... });
|
|
119
|
+
* A `Promise` is returned when `callback` is not provided.
|
|
121
120
|
*
|
|
122
121
|
* @example
|
|
123
|
-
* sharp(input)
|
|
124
|
-
* .
|
|
125
|
-
* .
|
|
126
|
-
* .catch(err => { ... });
|
|
122
|
+
* const data = await sharp(input)
|
|
123
|
+
* .png()
|
|
124
|
+
* .toBuffer();
|
|
127
125
|
*
|
|
128
126
|
* @example
|
|
129
|
-
* sharp(input)
|
|
127
|
+
* const { data, info } = await sharp(input)
|
|
130
128
|
* .png()
|
|
131
|
-
* .toBuffer({ resolveWithObject: true })
|
|
132
|
-
* .then(({ data, info }) => { ... })
|
|
133
|
-
* .catch(err => { ... });
|
|
129
|
+
* .toBuffer({ resolveWithObject: true });
|
|
134
130
|
*
|
|
135
131
|
* @example
|
|
136
132
|
* const { data, info } = await sharp('my-image.jpg')
|
|
@@ -1103,10 +1099,10 @@ function trySetAnimationOptions (source, target) {
|
|
|
1103
1099
|
* @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
|
|
1104
1100
|
* @param {boolean} [options.pyramid=false] - write an image pyramid
|
|
1105
1101
|
* @param {boolean} [options.tile=false] - write a tiled tiff
|
|
1106
|
-
* @param {number} [options.tileWidth=256] - horizontal tile size
|
|
1107
|
-
* @param {number} [options.tileHeight=256] - vertical tile size
|
|
1108
|
-
* @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm
|
|
1109
|
-
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
|
|
1102
|
+
* @param {number} [options.tileWidth=256] - horizontal tile size, valid values are integers in the range 1-32768
|
|
1103
|
+
* @param {number} [options.tileHeight=256] - vertical tile size, valid values are integers in the range 1-32768
|
|
1104
|
+
* @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000
|
|
1105
|
+
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000
|
|
1110
1106
|
* @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
|
|
1111
1107
|
* @param {number} [options.bitdepth=0] - reduce bitdepth to 1, 2 or 4 bit
|
|
1112
1108
|
* @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
|
|
@@ -1134,17 +1130,17 @@ function tiff (options) {
|
|
|
1134
1130
|
this._setBooleanOption('tiffTile', options.tile);
|
|
1135
1131
|
}
|
|
1136
1132
|
if (is.defined(options.tileWidth)) {
|
|
1137
|
-
if (is.integer(options.tileWidth) && options.tileWidth
|
|
1133
|
+
if (is.integer(options.tileWidth) && is.inRange(options.tileWidth, 1, 32768)) {
|
|
1138
1134
|
this.options.tiffTileWidth = options.tileWidth;
|
|
1139
1135
|
} else {
|
|
1140
|
-
throw is.invalidParameterError('tileWidth', 'integer
|
|
1136
|
+
throw is.invalidParameterError('tileWidth', 'integer between 1 and 32768', options.tileWidth);
|
|
1141
1137
|
}
|
|
1142
1138
|
}
|
|
1143
1139
|
if (is.defined(options.tileHeight)) {
|
|
1144
|
-
if (is.integer(options.tileHeight) && options.tileHeight
|
|
1140
|
+
if (is.integer(options.tileHeight) && is.inRange(options.tileHeight, 1, 32768)) {
|
|
1145
1141
|
this.options.tiffTileHeight = options.tileHeight;
|
|
1146
1142
|
} else {
|
|
1147
|
-
throw is.invalidParameterError('tileHeight', 'integer
|
|
1143
|
+
throw is.invalidParameterError('tileHeight', 'integer between 1 and 32768', options.tileHeight);
|
|
1148
1144
|
}
|
|
1149
1145
|
}
|
|
1150
1146
|
// miniswhite
|
|
@@ -1157,17 +1153,17 @@ function tiff (options) {
|
|
|
1157
1153
|
}
|
|
1158
1154
|
// resolution
|
|
1159
1155
|
if (is.defined(options.xres)) {
|
|
1160
|
-
if (is.number(options.xres) && options.xres
|
|
1156
|
+
if (is.number(options.xres) && is.inRange(options.xres, 0.001, 1000000)) {
|
|
1161
1157
|
this.options.tiffXres = options.xres;
|
|
1162
1158
|
} else {
|
|
1163
|
-
throw is.invalidParameterError('xres', 'number
|
|
1159
|
+
throw is.invalidParameterError('xres', 'number between 0.001 and 1000000', options.xres);
|
|
1164
1160
|
}
|
|
1165
1161
|
}
|
|
1166
1162
|
if (is.defined(options.yres)) {
|
|
1167
|
-
if (is.number(options.yres) && options.yres
|
|
1163
|
+
if (is.number(options.yres) && is.inRange(options.yres, 0.001, 1000000)) {
|
|
1168
1164
|
this.options.tiffYres = options.yres;
|
|
1169
1165
|
} else {
|
|
1170
|
-
throw is.invalidParameterError('yres', 'number
|
|
1166
|
+
throw is.invalidParameterError('yres', 'number between 0.001 and 1000000', options.yres);
|
|
1171
1167
|
}
|
|
1172
1168
|
}
|
|
1173
1169
|
// compression
|
package/dist/resize.cjs
CHANGED
|
@@ -386,48 +386,52 @@ function resize (widthOrOptions, height, options) {
|
|
|
386
386
|
* ...
|
|
387
387
|
*
|
|
388
388
|
* @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts
|
|
389
|
-
* @param {number} [extend.top=0]
|
|
390
|
-
* @param {number} [extend.left=0]
|
|
391
|
-
* @param {number} [extend.bottom=0]
|
|
392
|
-
* @param {number} [extend.right=0]
|
|
389
|
+
* @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-10000
|
|
390
|
+
* @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-10000
|
|
391
|
+
* @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-10000
|
|
392
|
+
* @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-10000
|
|
393
393
|
* @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror.
|
|
394
394
|
* @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.
|
|
395
395
|
* @returns {Sharp}
|
|
396
396
|
* @throws {Error} Invalid parameters
|
|
397
397
|
*/
|
|
398
398
|
function extend (extend) {
|
|
399
|
-
if (is.integer(extend)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
if (is.integer(extend)) {
|
|
400
|
+
if (is.inRange(extend, 1, 10000)) {
|
|
401
|
+
this.options.extendTop = extend;
|
|
402
|
+
this.options.extendBottom = extend;
|
|
403
|
+
this.options.extendLeft = extend;
|
|
404
|
+
this.options.extendRight = extend;
|
|
405
|
+
} else {
|
|
406
|
+
throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend);
|
|
407
|
+
}
|
|
404
408
|
} else if (is.object(extend)) {
|
|
405
409
|
if (is.defined(extend.top)) {
|
|
406
|
-
if (is.integer(extend.top) && extend.top
|
|
410
|
+
if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) {
|
|
407
411
|
this.options.extendTop = extend.top;
|
|
408
412
|
} else {
|
|
409
|
-
throw is.invalidParameterError('top', '
|
|
413
|
+
throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top);
|
|
410
414
|
}
|
|
411
415
|
}
|
|
412
416
|
if (is.defined(extend.bottom)) {
|
|
413
|
-
if (is.integer(extend.bottom) && extend.bottom
|
|
417
|
+
if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) {
|
|
414
418
|
this.options.extendBottom = extend.bottom;
|
|
415
419
|
} else {
|
|
416
|
-
throw is.invalidParameterError('bottom', '
|
|
420
|
+
throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom);
|
|
417
421
|
}
|
|
418
422
|
}
|
|
419
423
|
if (is.defined(extend.left)) {
|
|
420
|
-
if (is.integer(extend.left) && extend.left
|
|
424
|
+
if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) {
|
|
421
425
|
this.options.extendLeft = extend.left;
|
|
422
426
|
} else {
|
|
423
|
-
throw is.invalidParameterError('left', '
|
|
427
|
+
throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left);
|
|
424
428
|
}
|
|
425
429
|
}
|
|
426
430
|
if (is.defined(extend.right)) {
|
|
427
|
-
if (is.integer(extend.right) && extend.right
|
|
431
|
+
if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) {
|
|
428
432
|
this.options.extendRight = extend.right;
|
|
429
433
|
} else {
|
|
430
|
-
throw is.invalidParameterError('right', '
|
|
434
|
+
throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right);
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
437
|
this._setBackgroundColourOption('extendBackground', extend.background);
|
|
@@ -467,10 +471,10 @@ function extend (extend) {
|
|
|
467
471
|
* });
|
|
468
472
|
*
|
|
469
473
|
* @param {Object} options - describes the region to extract using integral pixel values
|
|
470
|
-
* @param {number} options.left - zero-indexed offset from left edge
|
|
471
|
-
* @param {number} options.top - zero-indexed offset from top edge
|
|
472
|
-
* @param {number} options.width - width of region to extract
|
|
473
|
-
* @param {number} options.height - height of region to extract
|
|
474
|
+
* @param {number} options.left - zero-indexed offset from left edge, an integer between 0 and 100000000
|
|
475
|
+
* @param {number} options.top - zero-indexed offset from top edge, an integer between 0 and 100000000
|
|
476
|
+
* @param {number} options.width - width of region to extract, an integer between 0 and 100000000
|
|
477
|
+
* @param {number} options.height - height of region to extract, an integer between 0 and 100000000
|
|
474
478
|
* @returns {Sharp}
|
|
475
479
|
* @throws {Error} Invalid parameters
|
|
476
480
|
*/
|
|
@@ -481,10 +485,10 @@ function extract (options) {
|
|
|
481
485
|
}
|
|
482
486
|
['left', 'top', 'width', 'height'].forEach(function (name) {
|
|
483
487
|
const value = options[name];
|
|
484
|
-
if (is.integer(value) && value
|
|
488
|
+
if (is.integer(value) && is.inRange(value, 0, 100000000)) {
|
|
485
489
|
this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
|
|
486
490
|
} else {
|
|
487
|
-
throw is.invalidParameterError(name, 'integer', value);
|
|
491
|
+
throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
|
|
488
492
|
}
|
|
489
493
|
}, this);
|
|
490
494
|
// Ensure existing rotation occurs before pre-resize extraction
|
|
@@ -554,7 +558,7 @@ function extract (options) {
|
|
|
554
558
|
* @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.
|
|
555
559
|
* @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.
|
|
556
560
|
* @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
|
|
557
|
-
* @param {number} [options.margin=0] - Leave a margin around trimmed content,
|
|
561
|
+
* @param {number} [options.margin=0] - Leave a margin around trimmed content, integral number of pixels between 0 and 10000000.
|
|
558
562
|
* @returns {Sharp}
|
|
559
563
|
* @throws {Error} Invalid parameters
|
|
560
564
|
*/
|
|
@@ -576,10 +580,10 @@ function trim (options) {
|
|
|
576
580
|
this._setBooleanOption('trimLineArt', options.lineArt);
|
|
577
581
|
}
|
|
578
582
|
if (is.defined(options.margin)) {
|
|
579
|
-
if (is.integer(options.margin) && options.margin
|
|
583
|
+
if (is.integer(options.margin) && is.inRange(options.margin, 0, 10000000)) {
|
|
580
584
|
this.options.trimMargin = options.margin;
|
|
581
585
|
} else {
|
|
582
|
-
throw is.invalidParameterError('margin', '
|
|
586
|
+
throw is.invalidParameterError('margin', 'integer between 0 and 10000000', options.margin);
|
|
583
587
|
}
|
|
584
588
|
}
|
|
585
589
|
} else {
|
package/dist/resize.mjs
CHANGED
|
@@ -386,48 +386,52 @@ function resize (widthOrOptions, height, options) {
|
|
|
386
386
|
* ...
|
|
387
387
|
*
|
|
388
388
|
* @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts
|
|
389
|
-
* @param {number} [extend.top=0]
|
|
390
|
-
* @param {number} [extend.left=0]
|
|
391
|
-
* @param {number} [extend.bottom=0]
|
|
392
|
-
* @param {number} [extend.right=0]
|
|
389
|
+
* @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-10000
|
|
390
|
+
* @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-10000
|
|
391
|
+
* @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-10000
|
|
392
|
+
* @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-10000
|
|
393
393
|
* @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror.
|
|
394
394
|
* @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.
|
|
395
395
|
* @returns {Sharp}
|
|
396
396
|
* @throws {Error} Invalid parameters
|
|
397
397
|
*/
|
|
398
398
|
function extend (extend) {
|
|
399
|
-
if (is.integer(extend)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
if (is.integer(extend)) {
|
|
400
|
+
if (is.inRange(extend, 1, 10000)) {
|
|
401
|
+
this.options.extendTop = extend;
|
|
402
|
+
this.options.extendBottom = extend;
|
|
403
|
+
this.options.extendLeft = extend;
|
|
404
|
+
this.options.extendRight = extend;
|
|
405
|
+
} else {
|
|
406
|
+
throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend);
|
|
407
|
+
}
|
|
404
408
|
} else if (is.object(extend)) {
|
|
405
409
|
if (is.defined(extend.top)) {
|
|
406
|
-
if (is.integer(extend.top) && extend.top
|
|
410
|
+
if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) {
|
|
407
411
|
this.options.extendTop = extend.top;
|
|
408
412
|
} else {
|
|
409
|
-
throw is.invalidParameterError('top', '
|
|
413
|
+
throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top);
|
|
410
414
|
}
|
|
411
415
|
}
|
|
412
416
|
if (is.defined(extend.bottom)) {
|
|
413
|
-
if (is.integer(extend.bottom) && extend.bottom
|
|
417
|
+
if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) {
|
|
414
418
|
this.options.extendBottom = extend.bottom;
|
|
415
419
|
} else {
|
|
416
|
-
throw is.invalidParameterError('bottom', '
|
|
420
|
+
throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom);
|
|
417
421
|
}
|
|
418
422
|
}
|
|
419
423
|
if (is.defined(extend.left)) {
|
|
420
|
-
if (is.integer(extend.left) && extend.left
|
|
424
|
+
if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) {
|
|
421
425
|
this.options.extendLeft = extend.left;
|
|
422
426
|
} else {
|
|
423
|
-
throw is.invalidParameterError('left', '
|
|
427
|
+
throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left);
|
|
424
428
|
}
|
|
425
429
|
}
|
|
426
430
|
if (is.defined(extend.right)) {
|
|
427
|
-
if (is.integer(extend.right) && extend.right
|
|
431
|
+
if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) {
|
|
428
432
|
this.options.extendRight = extend.right;
|
|
429
433
|
} else {
|
|
430
|
-
throw is.invalidParameterError('right', '
|
|
434
|
+
throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right);
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
437
|
this._setBackgroundColourOption('extendBackground', extend.background);
|
|
@@ -467,10 +471,10 @@ function extend (extend) {
|
|
|
467
471
|
* });
|
|
468
472
|
*
|
|
469
473
|
* @param {Object} options - describes the region to extract using integral pixel values
|
|
470
|
-
* @param {number} options.left - zero-indexed offset from left edge
|
|
471
|
-
* @param {number} options.top - zero-indexed offset from top edge
|
|
472
|
-
* @param {number} options.width - width of region to extract
|
|
473
|
-
* @param {number} options.height - height of region to extract
|
|
474
|
+
* @param {number} options.left - zero-indexed offset from left edge, an integer between 0 and 100000000
|
|
475
|
+
* @param {number} options.top - zero-indexed offset from top edge, an integer between 0 and 100000000
|
|
476
|
+
* @param {number} options.width - width of region to extract, an integer between 0 and 100000000
|
|
477
|
+
* @param {number} options.height - height of region to extract, an integer between 0 and 100000000
|
|
474
478
|
* @returns {Sharp}
|
|
475
479
|
* @throws {Error} Invalid parameters
|
|
476
480
|
*/
|
|
@@ -481,10 +485,10 @@ function extract (options) {
|
|
|
481
485
|
}
|
|
482
486
|
['left', 'top', 'width', 'height'].forEach(function (name) {
|
|
483
487
|
const value = options[name];
|
|
484
|
-
if (is.integer(value) && value
|
|
488
|
+
if (is.integer(value) && is.inRange(value, 0, 100000000)) {
|
|
485
489
|
this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
|
|
486
490
|
} else {
|
|
487
|
-
throw is.invalidParameterError(name, 'integer', value);
|
|
491
|
+
throw is.invalidParameterError(name, 'integer between 0 and 100000000', value);
|
|
488
492
|
}
|
|
489
493
|
}, this);
|
|
490
494
|
// Ensure existing rotation occurs before pre-resize extraction
|
|
@@ -554,7 +558,7 @@ function extract (options) {
|
|
|
554
558
|
* @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.
|
|
555
559
|
* @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.
|
|
556
560
|
* @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
|
|
557
|
-
* @param {number} [options.margin=0] - Leave a margin around trimmed content,
|
|
561
|
+
* @param {number} [options.margin=0] - Leave a margin around trimmed content, integral number of pixels between 0 and 10000000.
|
|
558
562
|
* @returns {Sharp}
|
|
559
563
|
* @throws {Error} Invalid parameters
|
|
560
564
|
*/
|
|
@@ -576,10 +580,10 @@ function trim (options) {
|
|
|
576
580
|
this._setBooleanOption('trimLineArt', options.lineArt);
|
|
577
581
|
}
|
|
578
582
|
if (is.defined(options.margin)) {
|
|
579
|
-
if (is.integer(options.margin) && options.margin
|
|
583
|
+
if (is.integer(options.margin) && is.inRange(options.margin, 0, 10000000)) {
|
|
580
584
|
this.options.trimMargin = options.margin;
|
|
581
585
|
} else {
|
|
582
|
-
throw is.invalidParameterError('margin', '
|
|
586
|
+
throw is.invalidParameterError('margin', 'integer between 0 and 10000000', options.margin);
|
|
583
587
|
}
|
|
584
588
|
}
|
|
585
589
|
} else {
|
package/dist/sharp.cjs
CHANGED
|
@@ -89,6 +89,12 @@ if (!sharp) {
|
|
|
89
89
|
errors.push(err);
|
|
90
90
|
sharp = null;
|
|
91
91
|
}
|
|
92
|
+
if (sharp && process.versions.electron && runtimePlatform.startsWith("linux")) {
|
|
93
|
+
process.emitWarning(
|
|
94
|
+
"Binaries provided by Electron for use on Linux may be incompatible with sharp - see https://sharp.pixelplumbing.com/install#electron-and-linux",
|
|
95
|
+
{ code: "SharpElectronLinux" }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
92
98
|
} catch (err) {
|
|
93
99
|
errors.push(err);
|
|
94
100
|
}
|
package/dist/sharp.mjs
CHANGED
|
@@ -89,6 +89,12 @@ if (!sharp) {
|
|
|
89
89
|
errors.push(err);
|
|
90
90
|
sharp = null;
|
|
91
91
|
}
|
|
92
|
+
if (sharp && process.versions.electron && runtimePlatform.startsWith("linux")) {
|
|
93
|
+
process.emitWarning(
|
|
94
|
+
"Binaries provided by Electron for use on Linux may be incompatible with sharp - see https://sharp.pixelplumbing.com/install#electron-and-linux",
|
|
95
|
+
{ code: "SharpElectronLinux" }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
92
98
|
} catch (err) {
|
|
93
99
|
errors.push(err);
|
|
94
100
|
}
|
package/dist/utility.cjs
CHANGED
|
@@ -114,6 +114,12 @@ function cache (options) {
|
|
|
114
114
|
return sharp.cache(0, 0, 0);
|
|
115
115
|
}
|
|
116
116
|
} else if (is.object(options)) {
|
|
117
|
+
for (const property of ['memory', 'files', 'items']) {
|
|
118
|
+
const value = options[property];
|
|
119
|
+
if (is.defined(value) && !(is.integer(value) && value >= 0)) {
|
|
120
|
+
throw is.invalidParameterError(property, 'a positive integer', value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
117
123
|
return sharp.cache(options.memory, options.files, options.items);
|
|
118
124
|
} else {
|
|
119
125
|
return sharp.cache();
|
|
@@ -155,7 +161,7 @@ function concurrency (concurrency) {
|
|
|
155
161
|
return sharp.concurrency(is.integer(concurrency) ? concurrency : null);
|
|
156
162
|
}
|
|
157
163
|
/* node:coverage ignore next 7 */
|
|
158
|
-
if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
|
|
164
|
+
if (!process.env.MALLOC_ARENA_MAX && detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
|
|
159
165
|
// Reduce default concurrency to 1 when using glibc memory allocator
|
|
160
166
|
sharp.concurrency(1);
|
|
161
167
|
} else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) {
|
package/dist/utility.mjs
CHANGED
|
@@ -114,6 +114,12 @@ function cache (options) {
|
|
|
114
114
|
return sharp.cache(0, 0, 0);
|
|
115
115
|
}
|
|
116
116
|
} else if (is.object(options)) {
|
|
117
|
+
for (const property of ['memory', 'files', 'items']) {
|
|
118
|
+
const value = options[property];
|
|
119
|
+
if (is.defined(value) && !(is.integer(value) && value >= 0)) {
|
|
120
|
+
throw is.invalidParameterError(property, 'a positive integer', value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
117
123
|
return sharp.cache(options.memory, options.files, options.items);
|
|
118
124
|
} else {
|
|
119
125
|
return sharp.cache();
|
|
@@ -155,7 +161,7 @@ function concurrency (concurrency) {
|
|
|
155
161
|
return sharp.concurrency(is.integer(concurrency) ? concurrency : null);
|
|
156
162
|
}
|
|
157
163
|
/* node:coverage ignore next 7 */
|
|
158
|
-
if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
|
|
164
|
+
if (!process.env.MALLOC_ARENA_MAX && detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
|
|
159
165
|
// Reduce default concurrency to 1 when using glibc memory allocator
|
|
160
166
|
sharp.concurrency(1);
|
|
161
167
|
} else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) {
|
package/lib/index.d.ts
CHANGED
|
@@ -658,25 +658,27 @@ declare namespace sharp {
|
|
|
658
658
|
* @param callback Callback function called on completion with three arguments (err, buffer, info).
|
|
659
659
|
* @returns A sharp instance that can be used to chain operations
|
|
660
660
|
*/
|
|
661
|
-
toBuffer(callback: (err: Error, buffer: Buffer
|
|
661
|
+
toBuffer(callback: (err: Error, buffer: Buffer<ArrayBuffer>, info: OutputInfo) => void): Sharp;
|
|
662
662
|
|
|
663
663
|
/**
|
|
664
664
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
665
665
|
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
666
|
+
* The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.
|
|
666
667
|
* @param options resolve options
|
|
667
668
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
668
669
|
* @returns A promise that resolves with the Buffer data.
|
|
669
670
|
*/
|
|
670
|
-
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer
|
|
671
|
+
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer<ArrayBuffer>>;
|
|
671
672
|
|
|
672
673
|
/**
|
|
673
674
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
674
675
|
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
676
|
+
* The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.
|
|
675
677
|
* @param options resolve options
|
|
676
678
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
677
679
|
* @returns A promise that resolves with an object containing the Buffer data and an info object containing the output image format, size (bytes), width, height and channels
|
|
678
680
|
*/
|
|
679
|
-
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer
|
|
681
|
+
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer<ArrayBuffer>; info: OutputInfo }>;
|
|
680
682
|
|
|
681
683
|
/**
|
|
682
684
|
* Write output to a Uint8Array backed by a transferable ArrayBuffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
@@ -1508,11 +1510,11 @@ declare namespace sharp {
|
|
|
1508
1510
|
tile?: boolean | undefined;
|
|
1509
1511
|
/** Horizontal tile size (optional, default 256) */
|
|
1510
1512
|
tileWidth?: number | undefined;
|
|
1511
|
-
/** Vertical tile size (optional, default 256) */
|
|
1513
|
+
/** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
|
|
1512
1514
|
tileHeight?: number | undefined;
|
|
1513
|
-
/** Horizontal resolution in pixels/mm (optional, default 1.0) */
|
|
1515
|
+
/** Horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1514
1516
|
xres?: number | undefined;
|
|
1515
|
-
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
|
1517
|
+
/** Vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1516
1518
|
yres?: number | undefined;
|
|
1517
1519
|
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1518
1520
|
bitdepth?: 1 | 2 | 4 | undefined;
|
|
@@ -1598,13 +1600,13 @@ declare namespace sharp {
|
|
|
1598
1600
|
}
|
|
1599
1601
|
|
|
1600
1602
|
interface Region {
|
|
1601
|
-
/** zero-indexed offset from left edge */
|
|
1603
|
+
/** zero-indexed offset from left edge, an integer between 0 and 100000000 */
|
|
1602
1604
|
left: number;
|
|
1603
|
-
/** zero-indexed offset from top edge */
|
|
1605
|
+
/** zero-indexed offset from top edge, an integer between 0 and 100000000 */
|
|
1604
1606
|
top: number;
|
|
1605
|
-
/** dimension of extracted image */
|
|
1607
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1606
1608
|
width: number;
|
|
1607
|
-
/** dimension of extracted image */
|
|
1609
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1608
1610
|
height: number;
|
|
1609
1611
|
}
|
|
1610
1612
|
|
|
@@ -1620,13 +1622,13 @@ declare namespace sharp {
|
|
|
1620
1622
|
type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
|
|
1621
1623
|
|
|
1622
1624
|
interface ExtendOptions {
|
|
1623
|
-
/** single pixel count to top edge (optional, default 0) */
|
|
1625
|
+
/** single pixel count to top edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1624
1626
|
top?: number | undefined;
|
|
1625
|
-
/** single pixel count to left edge (optional, default 0) */
|
|
1627
|
+
/** single pixel count to left edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1626
1628
|
left?: number | undefined;
|
|
1627
|
-
/** single pixel count to bottom edge (optional, default 0) */
|
|
1629
|
+
/** single pixel count to bottom edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1628
1630
|
bottom?: number | undefined;
|
|
1629
|
-
/** single pixel count to right edge (optional, default 0) */
|
|
1631
|
+
/** single pixel count to right edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1630
1632
|
right?: number | undefined;
|
|
1631
1633
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1632
1634
|
background?: ColorLike | undefined;
|
|
@@ -1641,7 +1643,7 @@ declare namespace sharp {
|
|
|
1641
1643
|
threshold?: number | undefined;
|
|
1642
1644
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1643
1645
|
lineArt?: boolean | undefined;
|
|
1644
|
-
/** Leave a margin around trimmed content,
|
|
1646
|
+
/** Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. (optional, default 0) */
|
|
1645
1647
|
margin?: number | undefined;
|
|
1646
1648
|
}
|
|
1647
1649
|
|
|
@@ -1669,11 +1671,11 @@ declare namespace sharp {
|
|
|
1669
1671
|
}
|
|
1670
1672
|
|
|
1671
1673
|
interface ClaheOptions {
|
|
1672
|
-
/** width of the region */
|
|
1674
|
+
/** width of the region. Valid values are integers in the range 1-65536. */
|
|
1673
1675
|
width: number;
|
|
1674
|
-
/** height of the region */
|
|
1676
|
+
/** height of the region. Valid values are integers in the range 1-65536. */
|
|
1675
1677
|
height: number;
|
|
1676
|
-
/** max slope of the cumulative contrast. A value of 0 disables contrast limiting. Valid values are integers in the range 0-100 (
|
|
1678
|
+
/** max slope of the cumulative contrast. A value of 0 disables contrast limiting. Valid values are integers in the range 0-100. (optional, default 3) */
|
|
1677
1679
|
maxSlope?: number | undefined;
|
|
1678
1680
|
}
|
|
1679
1681
|
|
|
@@ -1783,6 +1785,8 @@ declare namespace sharp {
|
|
|
1783
1785
|
channels: Channels;
|
|
1784
1786
|
/** indicating if premultiplication was used */
|
|
1785
1787
|
premultiplied: boolean;
|
|
1788
|
+
/** Indicates if the output image has an alpha channel */
|
|
1789
|
+
hasAlpha: boolean;
|
|
1786
1790
|
/** Only defined when using a crop strategy */
|
|
1787
1791
|
cropOffsetLeft?: number | undefined;
|
|
1788
1792
|
/** Only defined when using a crop strategy */
|
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.2",
|
|
4
|
+
"version": "0.35.3-rc.2",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -160,53 +160,58 @@
|
|
|
160
160
|
"dependencies": {
|
|
161
161
|
"@img/colour": "^1.1.0",
|
|
162
162
|
"detect-libc": "^2.1.2",
|
|
163
|
-
"semver": "^7.8.
|
|
163
|
+
"semver": "^7.8.5"
|
|
164
164
|
},
|
|
165
165
|
"optionalDependencies": {
|
|
166
|
-
"@img/sharp-darwin-arm64": "0.35.2",
|
|
167
|
-
"@img/sharp-darwin-x64": "0.35.2",
|
|
168
|
-
"@img/sharp-freebsd-wasm32": "0.35.2",
|
|
169
|
-
"@img/sharp-libvips-darwin-arm64": "1.3.
|
|
170
|
-
"@img/sharp-libvips-darwin-x64": "1.3.
|
|
171
|
-
"@img/sharp-libvips-linux-arm": "1.3.
|
|
172
|
-
"@img/sharp-libvips-linux-arm64": "1.3.
|
|
173
|
-
"@img/sharp-libvips-linux-ppc64": "1.3.
|
|
174
|
-
"@img/sharp-libvips-linux-riscv64": "1.3.
|
|
175
|
-
"@img/sharp-libvips-linux-s390x": "1.3.
|
|
176
|
-
"@img/sharp-libvips-linux-x64": "1.3.
|
|
177
|
-
"@img/sharp-libvips-linuxmusl-arm64": "1.3.
|
|
178
|
-
"@img/sharp-libvips-linuxmusl-x64": "1.3.
|
|
179
|
-
"@img/sharp-linux-arm": "0.35.2",
|
|
180
|
-
"@img/sharp-linux-arm64": "0.35.2",
|
|
181
|
-
"@img/sharp-linux-ppc64": "0.35.2",
|
|
182
|
-
"@img/sharp-linux-riscv64": "0.35.2",
|
|
183
|
-
"@img/sharp-linux-s390x": "0.35.2",
|
|
184
|
-
"@img/sharp-linux-x64": "0.35.2",
|
|
185
|
-
"@img/sharp-linuxmusl-arm64": "0.35.2",
|
|
186
|
-
"@img/sharp-linuxmusl-x64": "0.35.2",
|
|
187
|
-
"@img/sharp-webcontainers-wasm32": "0.35.2",
|
|
188
|
-
"@img/sharp-win32-arm64": "0.35.2",
|
|
189
|
-
"@img/sharp-win32-ia32": "0.35.2",
|
|
190
|
-
"@img/sharp-win32-x64": "0.35.2"
|
|
166
|
+
"@img/sharp-darwin-arm64": "0.35.3-rc.2",
|
|
167
|
+
"@img/sharp-darwin-x64": "0.35.3-rc.2",
|
|
168
|
+
"@img/sharp-freebsd-wasm32": "0.35.3-rc.2",
|
|
169
|
+
"@img/sharp-libvips-darwin-arm64": "1.3.2",
|
|
170
|
+
"@img/sharp-libvips-darwin-x64": "1.3.2",
|
|
171
|
+
"@img/sharp-libvips-linux-arm": "1.3.2",
|
|
172
|
+
"@img/sharp-libvips-linux-arm64": "1.3.2",
|
|
173
|
+
"@img/sharp-libvips-linux-ppc64": "1.3.2",
|
|
174
|
+
"@img/sharp-libvips-linux-riscv64": "1.3.2",
|
|
175
|
+
"@img/sharp-libvips-linux-s390x": "1.3.2",
|
|
176
|
+
"@img/sharp-libvips-linux-x64": "1.3.2",
|
|
177
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.3.2",
|
|
178
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.3.2",
|
|
179
|
+
"@img/sharp-linux-arm": "0.35.3-rc.2",
|
|
180
|
+
"@img/sharp-linux-arm64": "0.35.3-rc.2",
|
|
181
|
+
"@img/sharp-linux-ppc64": "0.35.3-rc.2",
|
|
182
|
+
"@img/sharp-linux-riscv64": "0.35.3-rc.2",
|
|
183
|
+
"@img/sharp-linux-s390x": "0.35.3-rc.2",
|
|
184
|
+
"@img/sharp-linux-x64": "0.35.3-rc.2",
|
|
185
|
+
"@img/sharp-linuxmusl-arm64": "0.35.3-rc.2",
|
|
186
|
+
"@img/sharp-linuxmusl-x64": "0.35.3-rc.2",
|
|
187
|
+
"@img/sharp-webcontainers-wasm32": "0.35.3-rc.2",
|
|
188
|
+
"@img/sharp-win32-arm64": "0.35.3-rc.2",
|
|
189
|
+
"@img/sharp-win32-ia32": "0.35.3-rc.2",
|
|
190
|
+
"@img/sharp-win32-x64": "0.35.3-rc.2"
|
|
191
|
+
},
|
|
192
|
+
"peerDependenciesMeta": {
|
|
193
|
+
"@types/node": {
|
|
194
|
+
"optional": true
|
|
195
|
+
}
|
|
191
196
|
},
|
|
192
197
|
"devDependencies": {
|
|
193
|
-
"@biomejs/biome": "^2.5.
|
|
198
|
+
"@biomejs/biome": "^2.5.1",
|
|
194
199
|
"@cpplint/cli": "^0.1.0",
|
|
195
200
|
"@emnapi/runtime": "^1.11.1",
|
|
196
|
-
"@img/sharp-libvips-dev": "1.3.
|
|
197
|
-
"@img/sharp-libvips-dev-wasm32": "1.3.
|
|
198
|
-
"@img/sharp-libvips-win32-arm64": "1.3.
|
|
199
|
-
"@img/sharp-libvips-win32-ia32": "1.3.
|
|
200
|
-
"@img/sharp-libvips-win32-x64": "1.3.
|
|
201
|
+
"@img/sharp-libvips-dev": "1.3.2",
|
|
202
|
+
"@img/sharp-libvips-dev-wasm32": "1.3.2",
|
|
203
|
+
"@img/sharp-libvips-win32-arm64": "1.3.2",
|
|
204
|
+
"@img/sharp-libvips-win32-ia32": "1.3.2",
|
|
205
|
+
"@img/sharp-libvips-win32-x64": "1.3.2",
|
|
201
206
|
"@types/node": "*",
|
|
202
207
|
"emnapi": "^1.11.1",
|
|
203
208
|
"exif-reader": "^2.0.3",
|
|
204
209
|
"extract-zip": "^2.0.1",
|
|
205
210
|
"icc": "^4.0.0",
|
|
206
|
-
"node-addon-api": "^8.
|
|
211
|
+
"node-addon-api": "^8.9.0",
|
|
207
212
|
"node-gyp": "^12.4.0",
|
|
208
213
|
"publint": "^0.3.21",
|
|
209
|
-
"tar-fs": "^3.1.
|
|
214
|
+
"tar-fs": "^3.1.3",
|
|
210
215
|
"tsd": "^0.33.0"
|
|
211
216
|
},
|
|
212
217
|
"license": "Apache-2.0",
|