sharp 0.35.2-rc.2 → 0.35.3-rc.1
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 +17 -15
- package/dist/index.d.mts +17 -15
- 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 +21 -13
- package/dist/operation.mjs +21 -13
- package/dist/output.cjs +12 -12
- package/dist/output.mjs +12 -12
- 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 +17 -15
- package/package.json +35 -35
- package/src/pipeline.cc +29 -30
- package/src/pipeline.h +2 -0
- package/src/utilities.cc +3 -3
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
|
@@ -1508,11 +1508,11 @@ declare namespace sharp {
|
|
|
1508
1508
|
tile?: boolean | undefined;
|
|
1509
1509
|
/** Horizontal tile size (optional, default 256) */
|
|
1510
1510
|
tileWidth?: number | undefined;
|
|
1511
|
-
/** Vertical tile size (optional, default 256) */
|
|
1511
|
+
/** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
|
|
1512
1512
|
tileHeight?: number | undefined;
|
|
1513
|
-
/** Horizontal resolution in pixels/mm (optional, default 1.0) */
|
|
1513
|
+
/** Horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1514
1514
|
xres?: number | undefined;
|
|
1515
|
-
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
|
1515
|
+
/** Vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1516
1516
|
yres?: number | undefined;
|
|
1517
1517
|
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1518
1518
|
bitdepth?: 1 | 2 | 4 | undefined;
|
|
@@ -1598,13 +1598,13 @@ declare namespace sharp {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
1600
|
interface Region {
|
|
1601
|
-
/** zero-indexed offset from left edge */
|
|
1601
|
+
/** zero-indexed offset from left edge, an integer between 0 and 100000000 */
|
|
1602
1602
|
left: number;
|
|
1603
|
-
/** zero-indexed offset from top edge */
|
|
1603
|
+
/** zero-indexed offset from top edge, an integer between 0 and 100000000 */
|
|
1604
1604
|
top: number;
|
|
1605
|
-
/** dimension of extracted image */
|
|
1605
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1606
1606
|
width: number;
|
|
1607
|
-
/** dimension of extracted image */
|
|
1607
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1608
1608
|
height: number;
|
|
1609
1609
|
}
|
|
1610
1610
|
|
|
@@ -1620,13 +1620,13 @@ declare namespace sharp {
|
|
|
1620
1620
|
type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
|
|
1621
1621
|
|
|
1622
1622
|
interface ExtendOptions {
|
|
1623
|
-
/** single pixel count to top edge (optional, default 0) */
|
|
1623
|
+
/** single pixel count to top edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1624
1624
|
top?: number | undefined;
|
|
1625
|
-
/** single pixel count to left edge (optional, default 0) */
|
|
1625
|
+
/** single pixel count to left edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1626
1626
|
left?: number | undefined;
|
|
1627
|
-
/** single pixel count to bottom edge (optional, default 0) */
|
|
1627
|
+
/** single pixel count to bottom edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1628
1628
|
bottom?: number | undefined;
|
|
1629
|
-
/** single pixel count to right edge (optional, default 0) */
|
|
1629
|
+
/** single pixel count to right edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1630
1630
|
right?: number | undefined;
|
|
1631
1631
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1632
1632
|
background?: ColorLike | undefined;
|
|
@@ -1641,7 +1641,7 @@ declare namespace sharp {
|
|
|
1641
1641
|
threshold?: number | undefined;
|
|
1642
1642
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1643
1643
|
lineArt?: boolean | undefined;
|
|
1644
|
-
/** Leave a margin around trimmed content,
|
|
1644
|
+
/** Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. (optional, default 0) */
|
|
1645
1645
|
margin?: number | undefined;
|
|
1646
1646
|
}
|
|
1647
1647
|
|
|
@@ -1669,11 +1669,11 @@ declare namespace sharp {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
|
|
1671
1671
|
interface ClaheOptions {
|
|
1672
|
-
/** width of the region */
|
|
1672
|
+
/** width of the region. Valid values are integers in the range 1-65536. */
|
|
1673
1673
|
width: number;
|
|
1674
|
-
/** height of the region */
|
|
1674
|
+
/** height of the region. Valid values are integers in the range 1-65536. */
|
|
1675
1675
|
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 (
|
|
1676
|
+
/** 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
1677
|
maxSlope?: number | undefined;
|
|
1678
1678
|
}
|
|
1679
1679
|
|
|
@@ -1783,6 +1783,8 @@ declare namespace sharp {
|
|
|
1783
1783
|
channels: Channels;
|
|
1784
1784
|
/** indicating if premultiplication was used */
|
|
1785
1785
|
premultiplied: boolean;
|
|
1786
|
+
/** Indicates if the output image has an alpha channel */
|
|
1787
|
+
hasAlpha: boolean;
|
|
1786
1788
|
/** Only defined when using a crop strategy */
|
|
1787
1789
|
cropOffsetLeft?: number | undefined;
|
|
1788
1790
|
/** 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.
|
|
4
|
+
"version": "0.35.3-rc.1",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -160,46 +160,46 @@
|
|
|
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.
|
|
167
|
-
"@img/sharp-darwin-x64": "0.35.
|
|
168
|
-
"@img/sharp-freebsd-wasm32": "0.35.
|
|
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.
|
|
180
|
-
"@img/sharp-linux-arm64": "0.35.
|
|
181
|
-
"@img/sharp-linux-ppc64": "0.35.
|
|
182
|
-
"@img/sharp-linux-riscv64": "0.35.
|
|
183
|
-
"@img/sharp-linux-s390x": "0.35.
|
|
184
|
-
"@img/sharp-linux-x64": "0.35.
|
|
185
|
-
"@img/sharp-linuxmusl-arm64": "0.35.
|
|
186
|
-
"@img/sharp-linuxmusl-x64": "0.35.
|
|
187
|
-
"@img/sharp-webcontainers-wasm32": "0.35.
|
|
188
|
-
"@img/sharp-win32-arm64": "0.35.
|
|
189
|
-
"@img/sharp-win32-ia32": "0.35.
|
|
190
|
-
"@img/sharp-win32-x64": "0.35.
|
|
166
|
+
"@img/sharp-darwin-arm64": "0.35.3-rc.1",
|
|
167
|
+
"@img/sharp-darwin-x64": "0.35.3-rc.1",
|
|
168
|
+
"@img/sharp-freebsd-wasm32": "0.35.3-rc.1",
|
|
169
|
+
"@img/sharp-libvips-darwin-arm64": "1.3.2-rc.0",
|
|
170
|
+
"@img/sharp-libvips-darwin-x64": "1.3.2-rc.0",
|
|
171
|
+
"@img/sharp-libvips-linux-arm": "1.3.2-rc.0",
|
|
172
|
+
"@img/sharp-libvips-linux-arm64": "1.3.2-rc.0",
|
|
173
|
+
"@img/sharp-libvips-linux-ppc64": "1.3.2-rc.0",
|
|
174
|
+
"@img/sharp-libvips-linux-riscv64": "1.3.2-rc.0",
|
|
175
|
+
"@img/sharp-libvips-linux-s390x": "1.3.2-rc.0",
|
|
176
|
+
"@img/sharp-libvips-linux-x64": "1.3.2-rc.0",
|
|
177
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.3.2-rc.0",
|
|
178
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.3.2-rc.0",
|
|
179
|
+
"@img/sharp-linux-arm": "0.35.3-rc.1",
|
|
180
|
+
"@img/sharp-linux-arm64": "0.35.3-rc.1",
|
|
181
|
+
"@img/sharp-linux-ppc64": "0.35.3-rc.1",
|
|
182
|
+
"@img/sharp-linux-riscv64": "0.35.3-rc.1",
|
|
183
|
+
"@img/sharp-linux-s390x": "0.35.3-rc.1",
|
|
184
|
+
"@img/sharp-linux-x64": "0.35.3-rc.1",
|
|
185
|
+
"@img/sharp-linuxmusl-arm64": "0.35.3-rc.1",
|
|
186
|
+
"@img/sharp-linuxmusl-x64": "0.35.3-rc.1",
|
|
187
|
+
"@img/sharp-webcontainers-wasm32": "0.35.3-rc.1",
|
|
188
|
+
"@img/sharp-win32-arm64": "0.35.3-rc.1",
|
|
189
|
+
"@img/sharp-win32-ia32": "0.35.3-rc.1",
|
|
190
|
+
"@img/sharp-win32-x64": "0.35.3-rc.1"
|
|
191
191
|
},
|
|
192
192
|
"devDependencies": {
|
|
193
|
-
"@biomejs/biome": "^2.5.
|
|
193
|
+
"@biomejs/biome": "^2.5.1",
|
|
194
194
|
"@cpplint/cli": "^0.1.0",
|
|
195
|
-
"@emnapi/runtime": "^1.11.
|
|
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.
|
|
195
|
+
"@emnapi/runtime": "^1.11.1",
|
|
196
|
+
"@img/sharp-libvips-dev": "1.3.2-rc.0",
|
|
197
|
+
"@img/sharp-libvips-dev-wasm32": "1.3.2-rc.0",
|
|
198
|
+
"@img/sharp-libvips-win32-arm64": "1.3.2-rc.0",
|
|
199
|
+
"@img/sharp-libvips-win32-ia32": "1.3.2-rc.0",
|
|
200
|
+
"@img/sharp-libvips-win32-x64": "1.3.2-rc.0",
|
|
201
201
|
"@types/node": "*",
|
|
202
|
-
"emnapi": "^1.11.
|
|
202
|
+
"emnapi": "^1.11.1",
|
|
203
203
|
"exif-reader": "^2.0.3",
|
|
204
204
|
"extract-zip": "^2.0.1",
|
|
205
205
|
"icc": "^4.0.0",
|
package/src/pipeline.cc
CHANGED
|
@@ -608,38 +608,25 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
608
608
|
baton->width = image.width() + baton->extendLeft + baton->extendRight;
|
|
609
609
|
baton->height = (nPages > 1 ? targetPageHeight : image.height()) + baton->extendTop + baton->extendBottom;
|
|
610
610
|
|
|
611
|
+
std::vector<double> background;
|
|
611
612
|
if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
|
|
612
|
-
std::vector<double> background;
|
|
613
613
|
std::tie(image, background) = sharp::ApplyAlpha(image, baton->extendBackground, shouldPremultiplyAlpha);
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
image = sharp::StaySequential(image);
|
|
631
|
-
image = nPages > 1
|
|
632
|
-
? sharp::EmbedMultiPage(image,
|
|
633
|
-
baton->extendLeft, baton->extendTop, baton->width, baton->height,
|
|
634
|
-
baton->extendWith, ignoredBackground, nPages, &targetPageHeight)
|
|
635
|
-
: image.embed(baton->extendLeft, baton->extendTop, baton->width, baton->height,
|
|
636
|
-
VImage::option()->set("extend", baton->extendWith));
|
|
637
|
-
if (baton->keepGainMap) {
|
|
638
|
-
gainMap = gainMap.embed(baton->extendLeft / gainMapScaleFactor, baton->extendTop / gainMapScaleFactor,
|
|
639
|
-
baton->width / gainMapScaleFactor, baton->height / gainMapScaleFactor, VImage::option()
|
|
640
|
-
->set("extend", baton->extendWith)
|
|
641
|
-
->set("background", 0));
|
|
642
|
-
}
|
|
614
|
+
}
|
|
615
|
+
image = sharp::StaySequential(image, nPages > 1 || baton->extendWith != VIPS_EXTEND_BACKGROUND);
|
|
616
|
+
auto options = VImage::option()->set("extend", baton->extendWith);
|
|
617
|
+
if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
|
|
618
|
+
options->set("background", background);
|
|
619
|
+
}
|
|
620
|
+
image = nPages > 1
|
|
621
|
+
? sharp::EmbedMultiPage(image,
|
|
622
|
+
baton->extendLeft, baton->extendTop, baton->width, baton->height,
|
|
623
|
+
baton->extendWith, background, nPages, &targetPageHeight)
|
|
624
|
+
: image.embed(baton->extendLeft, baton->extendTop, baton->width, baton->height, options);
|
|
625
|
+
if (baton->keepGainMap) {
|
|
626
|
+
gainMap = gainMap.embed(baton->extendLeft / gainMapScaleFactor, baton->extendTop / gainMapScaleFactor,
|
|
627
|
+
baton->width / gainMapScaleFactor, baton->height / gainMapScaleFactor, VImage::option()
|
|
628
|
+
->set("extend", baton->extendWith)
|
|
629
|
+
->set("background", 0));
|
|
643
630
|
}
|
|
644
631
|
}
|
|
645
632
|
// Median - must happen before blurring, due to the utility of blurring after thresholding
|
|
@@ -957,6 +944,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
957
944
|
baton->pageHeightOut = image.get_int(VIPS_META_PAGE_HEIGHT);
|
|
958
945
|
baton->pagesOut = image.get_int(VIPS_META_N_PAGES);
|
|
959
946
|
}
|
|
947
|
+
baton->hasAlphaOut = image.has_alpha();
|
|
960
948
|
|
|
961
949
|
// Output
|
|
962
950
|
sharp::SetTimeout(image, baton->timeoutSeconds);
|
|
@@ -996,6 +984,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
996
984
|
} else {
|
|
997
985
|
baton->channels = std::min(baton->channels, 3);
|
|
998
986
|
}
|
|
987
|
+
baton->hasAlphaOut = false;
|
|
999
988
|
} else if (baton->formatOut == "jp2" || (baton->formatOut == "input"
|
|
1000
989
|
&& inputImageType == sharp::ImageType::JP2)) {
|
|
1001
990
|
// Write JP2 to Buffer
|
|
@@ -1078,6 +1067,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1078
1067
|
if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) {
|
|
1079
1068
|
sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
|
|
1080
1069
|
baton->channels = std::min(baton->channels, 3);
|
|
1070
|
+
baton->hasAlphaOut = false;
|
|
1081
1071
|
}
|
|
1082
1072
|
// Cast pixel values to float, if required
|
|
1083
1073
|
if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
|
|
@@ -1137,6 +1127,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1137
1127
|
area->free_fn = nullptr;
|
|
1138
1128
|
vips_area_unref(area);
|
|
1139
1129
|
baton->formatOut = "dz";
|
|
1130
|
+
if (baton->tileFormat == "jpeg") {
|
|
1131
|
+
baton->hasAlphaOut = false;
|
|
1132
|
+
}
|
|
1140
1133
|
} else if (baton->formatOut == "jxl" ||
|
|
1141
1134
|
(baton->formatOut == "input" && inputImageType == sharp::ImageType::JXL)) {
|
|
1142
1135
|
// Write JXL to buffer
|
|
@@ -1224,6 +1217,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1224
1217
|
}
|
|
1225
1218
|
baton->formatOut = "jpeg";
|
|
1226
1219
|
baton->channels = std::min(baton->channels, 3);
|
|
1220
|
+
baton->hasAlphaOut = false;
|
|
1227
1221
|
} else if (baton->formatOut == "jp2" || (mightMatchInput && isJp2) ||
|
|
1228
1222
|
(willMatchInput && (inputImageType == sharp::ImageType::JP2))) {
|
|
1229
1223
|
// Write JP2 to file
|
|
@@ -1290,6 +1284,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1290
1284
|
if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) {
|
|
1291
1285
|
sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
|
|
1292
1286
|
baton->channels = std::min(baton->channels, 3);
|
|
1287
|
+
baton->hasAlphaOut = false;
|
|
1293
1288
|
}
|
|
1294
1289
|
// Cast pixel values to float, if required
|
|
1295
1290
|
if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
|
|
@@ -1350,6 +1345,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1350
1345
|
vips::VOption *options = BuildOptionsDZ(baton);
|
|
1351
1346
|
image.dzsave(const_cast<char*>(baton->fileOut.data()), options);
|
|
1352
1347
|
baton->formatOut = "dz";
|
|
1348
|
+
if (baton->tileFormat == "jpeg") {
|
|
1349
|
+
baton->hasAlphaOut = false;
|
|
1350
|
+
}
|
|
1353
1351
|
} else if (baton->formatOut == "v" || (mightMatchInput && isV) ||
|
|
1354
1352
|
(willMatchInput && inputImageType == sharp::ImageType::VIPS)) {
|
|
1355
1353
|
// Write V to file
|
|
@@ -1434,6 +1432,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1434
1432
|
info.Set("pageHeight", static_cast<int32_t>(baton->pageHeightOut));
|
|
1435
1433
|
info.Set("pages", static_cast<int32_t>(baton->pagesOut));
|
|
1436
1434
|
}
|
|
1435
|
+
info.Set("hasAlpha", baton->hasAlphaOut);
|
|
1437
1436
|
|
|
1438
1437
|
if (baton->bufferOutLength > 0) {
|
|
1439
1438
|
info.Set("size", static_cast<uint32_t>(baton->bufferOutLength));
|
package/src/pipeline.h
CHANGED
|
@@ -49,6 +49,7 @@ struct PipelineBaton {
|
|
|
49
49
|
int pageHeightOut;
|
|
50
50
|
int pagesOut;
|
|
51
51
|
bool typedArrayOut;
|
|
52
|
+
bool hasAlphaOut;
|
|
52
53
|
std::vector<Composite *> composite;
|
|
53
54
|
std::vector<sharp::InputDescriptor *> joinChannelIn;
|
|
54
55
|
int topOffsetPre;
|
|
@@ -249,6 +250,7 @@ struct PipelineBaton {
|
|
|
249
250
|
pageHeightOut(0),
|
|
250
251
|
pagesOut(0),
|
|
251
252
|
typedArrayOut(false),
|
|
253
|
+
hasAlphaOut(false),
|
|
252
254
|
topOffsetPre(-1),
|
|
253
255
|
topOffsetPost(-1),
|
|
254
256
|
channels(0),
|