sharp 0.33.5 → 0.34.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/channel.js +2 -1
- package/lib/colour.js +3 -2
- package/lib/composite.js +4 -2
- package/lib/constructor.js +29 -2
- package/lib/index.d.ts +150 -55
- package/lib/input.js +92 -16
- package/lib/operation.js +44 -25
- package/lib/output.js +11 -9
- package/lib/resize.js +5 -2
- package/lib/utility.js +1 -0
- package/package.json +39 -39
- package/src/binding.gyp +15 -8
- package/src/common.cc +42 -15
- package/src/common.h +26 -19
- package/src/metadata.cc +26 -8
- package/src/metadata.h +4 -2
- package/src/operations.cc +9 -9
- package/src/pipeline.cc +93 -36
- package/src/pipeline.h +3 -2
- package/src/stats.cc +1 -1
- package/src/utilities.cc +3 -3
package/lib/input.js
CHANGED
|
@@ -8,15 +8,19 @@ const is = require('./is');
|
|
|
8
8
|
const sharp = require('./sharp');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Justification alignment
|
|
12
12
|
* @member
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
15
15
|
const align = {
|
|
16
16
|
left: 'low',
|
|
17
|
+
top: 'low',
|
|
18
|
+
low: 'low',
|
|
17
19
|
center: 'centre',
|
|
18
20
|
centre: 'centre',
|
|
19
|
-
right: 'high'
|
|
21
|
+
right: 'high',
|
|
22
|
+
bottom: 'high',
|
|
23
|
+
high: 'high'
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
/**
|
|
@@ -24,9 +28,9 @@ const align = {
|
|
|
24
28
|
* @private
|
|
25
29
|
*/
|
|
26
30
|
function _inputOptionsFromObject (obj) {
|
|
27
|
-
const { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd } = obj;
|
|
28
|
-
return [raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd].some(is.defined)
|
|
29
|
-
? { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd }
|
|
31
|
+
const { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground, autoOrient } = obj;
|
|
32
|
+
return [raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground, autoOrient].some(is.defined)
|
|
33
|
+
? { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground, autoOrient }
|
|
30
34
|
: undefined;
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -36,6 +40,7 @@ function _inputOptionsFromObject (obj) {
|
|
|
36
40
|
*/
|
|
37
41
|
function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
38
42
|
const inputDescriptor = {
|
|
43
|
+
autoOrient: false,
|
|
39
44
|
failOn: 'warning',
|
|
40
45
|
limitInputPixels: Math.pow(0x3FFF, 2),
|
|
41
46
|
ignoreIcc: false,
|
|
@@ -71,6 +76,18 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
71
76
|
} else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {
|
|
72
77
|
// Stream without options
|
|
73
78
|
inputDescriptor.buffer = [];
|
|
79
|
+
} else if (Array.isArray(input)) {
|
|
80
|
+
if (input.length > 1) {
|
|
81
|
+
// Join images together
|
|
82
|
+
if (!this.options.joining) {
|
|
83
|
+
this.options.joining = true;
|
|
84
|
+
this.options.join = input.map(i => this._createInputDescriptor(i));
|
|
85
|
+
} else {
|
|
86
|
+
throw new Error('Recursive join is unsupported');
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error('Expected at least two images to join');
|
|
90
|
+
}
|
|
74
91
|
} else {
|
|
75
92
|
throw new Error(`Unsupported input '${input}' of type ${typeof input}${
|
|
76
93
|
is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ''
|
|
@@ -93,6 +110,14 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
93
110
|
throw is.invalidParameterError('failOn', 'one of: none, truncated, error, warning', inputOptions.failOn);
|
|
94
111
|
}
|
|
95
112
|
}
|
|
113
|
+
// autoOrient
|
|
114
|
+
if (is.defined(inputOptions.autoOrient)) {
|
|
115
|
+
if (is.bool(inputOptions.autoOrient)) {
|
|
116
|
+
inputDescriptor.autoOrient = inputOptions.autoOrient;
|
|
117
|
+
} else {
|
|
118
|
+
throw is.invalidParameterError('autoOrient', 'boolean', inputOptions.autoOrient);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
96
121
|
// Density
|
|
97
122
|
if (is.defined(inputOptions.density)) {
|
|
98
123
|
if (is.inRange(inputOptions.density, 1, 100000)) {
|
|
@@ -222,6 +247,10 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
222
247
|
throw is.invalidParameterError('subifd', 'integer between -1 and 100000', inputOptions.subifd);
|
|
223
248
|
}
|
|
224
249
|
}
|
|
250
|
+
// PDF background colour
|
|
251
|
+
if (is.defined(inputOptions.pdfBackground)) {
|
|
252
|
+
this._setBackgroundColourOption('pdfBackground', inputOptions.pdfBackground);
|
|
253
|
+
}
|
|
225
254
|
// Create new image
|
|
226
255
|
if (is.defined(inputOptions.create)) {
|
|
227
256
|
if (
|
|
@@ -356,6 +385,57 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
356
385
|
throw new Error('Expected a valid string to create an image with text.');
|
|
357
386
|
}
|
|
358
387
|
}
|
|
388
|
+
// Join images together
|
|
389
|
+
if (is.defined(inputOptions.join)) {
|
|
390
|
+
if (is.defined(this.options.join)) {
|
|
391
|
+
if (is.defined(inputOptions.join.animated)) {
|
|
392
|
+
if (is.bool(inputOptions.join.animated)) {
|
|
393
|
+
inputDescriptor.joinAnimated = inputOptions.join.animated;
|
|
394
|
+
} else {
|
|
395
|
+
throw is.invalidParameterError('join.animated', 'boolean', inputOptions.join.animated);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (is.defined(inputOptions.join.across)) {
|
|
399
|
+
if (is.integer(inputOptions.join.across) && is.inRange(inputOptions.join.across, 1, 1000000)) {
|
|
400
|
+
inputDescriptor.joinAcross = inputOptions.join.across;
|
|
401
|
+
} else {
|
|
402
|
+
throw is.invalidParameterError('join.across', 'integer between 1 and 100000', inputOptions.join.across);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (is.defined(inputOptions.join.shim)) {
|
|
406
|
+
if (is.integer(inputOptions.join.shim) && is.inRange(inputOptions.join.shim, 0, 1000000)) {
|
|
407
|
+
inputDescriptor.joinShim = inputOptions.join.shim;
|
|
408
|
+
} else {
|
|
409
|
+
throw is.invalidParameterError('join.shim', 'integer between 0 and 100000', inputOptions.join.shim);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (is.defined(inputOptions.join.background)) {
|
|
413
|
+
const background = color(inputOptions.join.background);
|
|
414
|
+
inputDescriptor.joinBackground = [
|
|
415
|
+
background.red(),
|
|
416
|
+
background.green(),
|
|
417
|
+
background.blue(),
|
|
418
|
+
Math.round(background.alpha() * 255)
|
|
419
|
+
];
|
|
420
|
+
}
|
|
421
|
+
if (is.defined(inputOptions.join.halign)) {
|
|
422
|
+
if (is.string(inputOptions.join.halign) && is.string(this.constructor.align[inputOptions.join.halign])) {
|
|
423
|
+
inputDescriptor.joinHalign = this.constructor.align[inputOptions.join.halign];
|
|
424
|
+
} else {
|
|
425
|
+
throw is.invalidParameterError('join.halign', 'valid alignment', inputOptions.join.halign);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (is.defined(inputOptions.join.valign)) {
|
|
429
|
+
if (is.string(inputOptions.join.valign) && is.string(this.constructor.align[inputOptions.join.valign])) {
|
|
430
|
+
inputDescriptor.joinValign = this.constructor.align[inputOptions.join.valign];
|
|
431
|
+
} else {
|
|
432
|
+
throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} else {
|
|
436
|
+
throw new Error('Expected input to be an array of images to join');
|
|
437
|
+
}
|
|
438
|
+
}
|
|
359
439
|
} else if (is.defined(inputOptions)) {
|
|
360
440
|
throw new Error('Invalid input options ' + inputOptions);
|
|
361
441
|
}
|
|
@@ -430,15 +510,16 @@ function _isStreamInput () {
|
|
|
430
510
|
* - `density`: Number of pixels per inch (DPI), if present
|
|
431
511
|
* - `chromaSubsampling`: String containing JPEG chroma subsampling, `4:2:0` or `4:4:4` for RGB, `4:2:0:4` or `4:4:4:4` for CMYK
|
|
432
512
|
* - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan
|
|
513
|
+
* - `isPalette`: Boolean indicating whether the image is palette-based (GIF, PNG).
|
|
514
|
+
* - `bitsPerSample`: Number of bits per sample for each channel (GIF, PNG, HEIF).
|
|
433
515
|
* - `pages`: Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP
|
|
434
516
|
* - `pageHeight`: Number of pixels high each page in a multi-page image will be.
|
|
435
|
-
* - `paletteBitDepth`: Bit depth of palette-based image (GIF, PNG).
|
|
436
517
|
* - `loop`: Number of times to loop an animated image, zero refers to a continuous loop.
|
|
437
518
|
* - `delay`: Delay in ms between each page in an animated image, provided as an array of integers.
|
|
438
519
|
* - `pagePrimary`: Number of the primary page in a HEIF image
|
|
439
520
|
* - `levels`: Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide
|
|
440
521
|
* - `subifds`: Number of Sub Image File Directories in an OME-TIFF image
|
|
441
|
-
* - `background`: Default background colour, if present, for PNG (bKGD) and GIF images
|
|
522
|
+
* - `background`: Default background colour, if present, for PNG (bKGD) and GIF images
|
|
442
523
|
* - `compression`: The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC)
|
|
443
524
|
* - `resolutionUnit`: The unit of resolution (density), either `inch` or `cm`, if present
|
|
444
525
|
* - `hasProfile`: Boolean indicating the presence of an embedded ICC profile
|
|
@@ -470,15 +551,9 @@ function _isStreamInput () {
|
|
|
470
551
|
* });
|
|
471
552
|
*
|
|
472
553
|
* @example
|
|
473
|
-
* //
|
|
474
|
-
*
|
|
475
|
-
* const
|
|
476
|
-
*
|
|
477
|
-
* function getNormalSize({ width, height, orientation }) {
|
|
478
|
-
* return (orientation || 0) >= 5
|
|
479
|
-
* ? { width: height, height: width }
|
|
480
|
-
* : { width, height };
|
|
481
|
-
* }
|
|
554
|
+
* // Get dimensions taking EXIF Orientation into account.
|
|
555
|
+
* const { autoOrient } = await sharp(input).metadata();
|
|
556
|
+
* const { width, height } = autoOrient;
|
|
482
557
|
*
|
|
483
558
|
* @param {Function} [callback] - called with the arguments `(err, metadata)`
|
|
484
559
|
* @returns {Promise<Object>|Sharp}
|
|
@@ -639,6 +714,7 @@ function stats (callback) {
|
|
|
639
714
|
|
|
640
715
|
/**
|
|
641
716
|
* Decorate the Sharp prototype with input-related functions.
|
|
717
|
+
* @module Sharp
|
|
642
718
|
* @private
|
|
643
719
|
*/
|
|
644
720
|
module.exports = function (Sharp) {
|
package/lib/operation.js
CHANGED
|
@@ -18,22 +18,19 @@ const vipsPrecision = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Rotate the output image
|
|
22
|
-
* or auto-orient based on the EXIF `Orientation` tag.
|
|
21
|
+
* Rotate the output image.
|
|
23
22
|
*
|
|
24
|
-
*
|
|
23
|
+
* The provided angle is converted to a valid positive degree rotation.
|
|
25
24
|
* For example, `-450` will produce a 270 degree rotation.
|
|
26
25
|
*
|
|
27
26
|
* When rotating by an angle other than a multiple of 90,
|
|
28
27
|
* the background colour can be provided with the `background` option.
|
|
29
28
|
*
|
|
30
|
-
*
|
|
31
|
-
* Mirroring is supported and may infer the use of a flip operation.
|
|
32
|
-
*
|
|
33
|
-
* The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if any.
|
|
29
|
+
* For backwards compatibility, if no angle is provided, `.autoOrient()` will be called.
|
|
34
30
|
*
|
|
35
|
-
* Only one rotation can occur per pipeline
|
|
36
|
-
* Previous calls to `rotate` in the same
|
|
31
|
+
* Only one rotation can occur per pipeline (aside from an initial call without
|
|
32
|
+
* arguments to orient via EXIF data). Previous calls to `rotate` in the same
|
|
33
|
+
* pipeline will be ignored.
|
|
37
34
|
*
|
|
38
35
|
* Multi-page images can only be rotated by 180 degrees.
|
|
39
36
|
*
|
|
@@ -41,17 +38,6 @@ const vipsPrecision = {
|
|
|
41
38
|
* for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
|
42
39
|
*
|
|
43
40
|
* @example
|
|
44
|
-
* const pipeline = sharp()
|
|
45
|
-
* .rotate()
|
|
46
|
-
* .resize(null, 200)
|
|
47
|
-
* .toBuffer(function (err, outputBuffer, info) {
|
|
48
|
-
* // outputBuffer contains 200px high JPEG image data,
|
|
49
|
-
* // auto-rotated using EXIF Orientation tag
|
|
50
|
-
* // info.width and info.height contain the dimensions of the resized image
|
|
51
|
-
* });
|
|
52
|
-
* readableStream.pipe(pipeline);
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
41
|
* const rotateThenResize = await sharp(input)
|
|
56
42
|
* .rotate(90)
|
|
57
43
|
* .resize({ width: 16, height: 8, fit: 'fill' })
|
|
@@ -68,12 +54,15 @@ const vipsPrecision = {
|
|
|
68
54
|
* @throws {Error} Invalid parameters
|
|
69
55
|
*/
|
|
70
56
|
function rotate (angle, options) {
|
|
71
|
-
if (
|
|
57
|
+
if (!is.defined(angle)) {
|
|
58
|
+
return this.autoOrient();
|
|
59
|
+
}
|
|
60
|
+
if (this.options.angle || this.options.rotationAngle) {
|
|
72
61
|
this.options.debuglog('ignoring previous rotate options');
|
|
62
|
+
this.options.angle = 0;
|
|
63
|
+
this.options.rotationAngle = 0;
|
|
73
64
|
}
|
|
74
|
-
if (
|
|
75
|
-
this.options.useExifOrientation = true;
|
|
76
|
-
} else if (is.integer(angle) && !(angle % 90)) {
|
|
65
|
+
if (is.integer(angle) && !(angle % 90)) {
|
|
77
66
|
this.options.angle = angle;
|
|
78
67
|
} else if (is.number(angle)) {
|
|
79
68
|
this.options.rotationAngle = angle;
|
|
@@ -92,6 +81,34 @@ function rotate (angle, options) {
|
|
|
92
81
|
return this;
|
|
93
82
|
}
|
|
94
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Auto-orient based on the EXIF `Orientation` tag, then remove the tag.
|
|
86
|
+
* Mirroring is supported and may infer the use of a flip operation.
|
|
87
|
+
*
|
|
88
|
+
* Previous or subsequent use of `rotate(angle)` and either `flip()` or `flop()`
|
|
89
|
+
* will logically occur after auto-orientation, regardless of call order.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* const output = await sharp(input).autoOrient().toBuffer();
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* const pipeline = sharp()
|
|
96
|
+
* .autoOrient()
|
|
97
|
+
* .resize(null, 200)
|
|
98
|
+
* .toBuffer(function (err, outputBuffer, info) {
|
|
99
|
+
* // outputBuffer contains 200px high JPEG image data,
|
|
100
|
+
* // auto-oriented using EXIF Orientation tag
|
|
101
|
+
* // info.width and info.height contain the dimensions of the resized image
|
|
102
|
+
* });
|
|
103
|
+
* readableStream.pipe(pipeline);
|
|
104
|
+
*
|
|
105
|
+
* @returns {Sharp}
|
|
106
|
+
*/
|
|
107
|
+
function autoOrient () {
|
|
108
|
+
this.options.input.autoOrient = true;
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
95
112
|
/**
|
|
96
113
|
* Mirror the image vertically (up-down) about the x-axis.
|
|
97
114
|
* This always occurs before rotation, if any.
|
|
@@ -128,7 +145,7 @@ function flop (flop) {
|
|
|
128
145
|
* Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.
|
|
129
146
|
*
|
|
130
147
|
* You must provide an array of length 4 or a 2x2 affine transformation matrix.
|
|
131
|
-
* By default, new pixels are filled with a black background. You can provide a background
|
|
148
|
+
* By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
|
|
132
149
|
* A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
|
|
133
150
|
*
|
|
134
151
|
* In the case of a 2x2 matrix, the transform is:
|
|
@@ -930,10 +947,12 @@ function modulate (options) {
|
|
|
930
947
|
|
|
931
948
|
/**
|
|
932
949
|
* Decorate the Sharp prototype with operation-related functions.
|
|
950
|
+
* @module Sharp
|
|
933
951
|
* @private
|
|
934
952
|
*/
|
|
935
953
|
module.exports = function (Sharp) {
|
|
936
954
|
Object.assign(Sharp.prototype, {
|
|
955
|
+
autoOrient,
|
|
937
956
|
rotate,
|
|
938
957
|
flip,
|
|
939
958
|
flop,
|
package/lib/output.js
CHANGED
|
@@ -623,6 +623,7 @@ function png (options) {
|
|
|
623
623
|
* @param {boolean} [options.lossless=false] - use lossless compression mode
|
|
624
624
|
* @param {boolean} [options.nearLossless=false] - use near_lossless compression mode
|
|
625
625
|
* @param {boolean} [options.smartSubsample=false] - use high quality chroma subsampling
|
|
626
|
+
* @param {boolean} [options.smartDeblock=false] - auto-adjust the deblocking filter, can improve low contrast edges (slow)
|
|
626
627
|
* @param {string} [options.preset='default'] - named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text
|
|
627
628
|
* @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 6 (slowest)
|
|
628
629
|
* @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
|
|
@@ -658,6 +659,9 @@ function webp (options) {
|
|
|
658
659
|
if (is.defined(options.smartSubsample)) {
|
|
659
660
|
this._setBooleanOption('webpSmartSubsample', options.smartSubsample);
|
|
660
661
|
}
|
|
662
|
+
if (is.defined(options.smartDeblock)) {
|
|
663
|
+
this._setBooleanOption('webpSmartDeblock', options.smartDeblock);
|
|
664
|
+
}
|
|
661
665
|
if (is.defined(options.preset)) {
|
|
662
666
|
if (is.string(options.preset) && is.inArray(options.preset, ['default', 'photo', 'picture', 'drawing', 'icon', 'text'])) {
|
|
663
667
|
this.options.webpPreset = options.preset;
|
|
@@ -1123,8 +1127,6 @@ function heif (options) {
|
|
|
1123
1127
|
* The prebuilt binaries do not include this - see
|
|
1124
1128
|
* {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
|
|
1125
1129
|
*
|
|
1126
|
-
* Image metadata (EXIF, XMP) is unsupported.
|
|
1127
|
-
*
|
|
1128
1130
|
* @since 0.31.3
|
|
1129
1131
|
*
|
|
1130
1132
|
* @param {Object} [options] - output options
|
|
@@ -1132,7 +1134,9 @@ function heif (options) {
|
|
|
1132
1134
|
* @param {number} [options.quality] - calculate `distance` based on JPEG-like quality, between 1 and 100, overrides distance if specified
|
|
1133
1135
|
* @param {number} [options.decodingTier=0] - target decode speed tier, between 0 (highest quality) and 4 (lowest quality)
|
|
1134
1136
|
* @param {boolean} [options.lossless=false] - use lossless compression
|
|
1135
|
-
* @param {number} [options.effort=7] - CPU effort, between
|
|
1137
|
+
* @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 9 (slowest)
|
|
1138
|
+
* @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
|
|
1139
|
+
* @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
|
|
1136
1140
|
* @returns {Sharp}
|
|
1137
1141
|
* @throws {Error} Invalid options
|
|
1138
1142
|
*/
|
|
@@ -1169,13 +1173,14 @@ function jxl (options) {
|
|
|
1169
1173
|
}
|
|
1170
1174
|
}
|
|
1171
1175
|
if (is.defined(options.effort)) {
|
|
1172
|
-
if (is.integer(options.effort) && is.inRange(options.effort,
|
|
1176
|
+
if (is.integer(options.effort) && is.inRange(options.effort, 1, 9)) {
|
|
1173
1177
|
this.options.jxlEffort = options.effort;
|
|
1174
1178
|
} else {
|
|
1175
|
-
throw is.invalidParameterError('effort', 'integer between
|
|
1179
|
+
throw is.invalidParameterError('effort', 'integer between 1 and 9', options.effort);
|
|
1176
1180
|
}
|
|
1177
1181
|
}
|
|
1178
1182
|
}
|
|
1183
|
+
trySetAnimationOptions(options, this.options);
|
|
1179
1184
|
return this._updateFormatOut('jxl', options);
|
|
1180
1185
|
}
|
|
1181
1186
|
|
|
@@ -1227,10 +1232,6 @@ function raw (options) {
|
|
|
1227
1232
|
*
|
|
1228
1233
|
* The container will be set to `zip` when the output is a Buffer or Stream, otherwise it will default to `fs`.
|
|
1229
1234
|
*
|
|
1230
|
-
* Requires libvips compiled with support for libgsf.
|
|
1231
|
-
* The prebuilt binaries do not include this - see
|
|
1232
|
-
* {@link https://sharp.pixelplumbing.com/install#custom-libvips installing a custom libvips}.
|
|
1233
|
-
*
|
|
1234
1235
|
* @example
|
|
1235
1236
|
* sharp('input.tiff')
|
|
1236
1237
|
* .png()
|
|
@@ -1551,6 +1552,7 @@ function _pipeline (callback, stack) {
|
|
|
1551
1552
|
|
|
1552
1553
|
/**
|
|
1553
1554
|
* Decorate the Sharp prototype with output-related functions.
|
|
1555
|
+
* @module Sharp
|
|
1554
1556
|
* @private
|
|
1555
1557
|
*/
|
|
1556
1558
|
module.exports = function (Sharp) {
|
package/lib/resize.js
CHANGED
|
@@ -72,7 +72,9 @@ const kernel = {
|
|
|
72
72
|
cubic: 'cubic',
|
|
73
73
|
mitchell: 'mitchell',
|
|
74
74
|
lanczos2: 'lanczos2',
|
|
75
|
-
lanczos3: 'lanczos3'
|
|
75
|
+
lanczos3: 'lanczos3',
|
|
76
|
+
mks2013: 'mks2013',
|
|
77
|
+
mks2021: 'mks2021'
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
/**
|
|
@@ -105,7 +107,7 @@ const mapFitToCanvas = {
|
|
|
105
107
|
* @private
|
|
106
108
|
*/
|
|
107
109
|
function isRotationExpected (options) {
|
|
108
|
-
return (options.angle % 360) !== 0 || options.
|
|
110
|
+
return (options.angle % 360) !== 0 || options.input.autoOrient === true || options.rotationAngle !== 0;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
/**
|
|
@@ -569,6 +571,7 @@ function trim (options) {
|
|
|
569
571
|
|
|
570
572
|
/**
|
|
571
573
|
* Decorate the Sharp prototype with resize-related functions.
|
|
574
|
+
* @module Sharp
|
|
572
575
|
* @private
|
|
573
576
|
*/
|
|
574
577
|
module.exports = function (Sharp) {
|
package/lib/utility.js
CHANGED
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.34.0-rc.0",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
"test-types": "tsd",
|
|
103
103
|
"package-from-local-build": "node npm/from-local-build",
|
|
104
104
|
"package-from-github-release": "node npm/from-github-release",
|
|
105
|
-
"docs-build": "node docs/build
|
|
106
|
-
"docs-serve": "cd docs &&
|
|
107
|
-
"docs-publish": "cd docs && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
|
105
|
+
"docs-build": "node docs/build.mjs",
|
|
106
|
+
"docs-serve": "cd docs && npm start",
|
|
107
|
+
"docs-publish": "cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
|
108
108
|
},
|
|
109
109
|
"type": "commonjs",
|
|
110
110
|
"main": "lib/index.js",
|
|
@@ -139,58 +139,58 @@
|
|
|
139
139
|
"dependencies": {
|
|
140
140
|
"color": "^4.2.3",
|
|
141
141
|
"detect-libc": "^2.0.3",
|
|
142
|
-
"semver": "^7.
|
|
142
|
+
"semver": "^7.7.1"
|
|
143
143
|
},
|
|
144
144
|
"optionalDependencies": {
|
|
145
|
-
"@img/sharp-darwin-arm64": "0.
|
|
146
|
-
"@img/sharp-darwin-x64": "0.
|
|
147
|
-
"@img/sharp-libvips-darwin-arm64": "1.0
|
|
148
|
-
"@img/sharp-libvips-darwin-x64": "1.0
|
|
149
|
-
"@img/sharp-libvips-linux-arm": "1.0.
|
|
150
|
-
"@img/sharp-libvips-linux-arm64": "1.0
|
|
151
|
-
"@img/sharp-libvips-linux-
|
|
152
|
-
"@img/sharp-libvips-linux-
|
|
153
|
-
"@img/sharp-libvips-
|
|
154
|
-
"@img/sharp-libvips-linuxmusl-
|
|
155
|
-
"@img/sharp-
|
|
156
|
-
"@img/sharp-linux-
|
|
157
|
-
"@img/sharp-linux-
|
|
158
|
-
"@img/sharp-linux-
|
|
159
|
-
"@img/sharp-
|
|
160
|
-
"@img/sharp-linuxmusl-
|
|
161
|
-
"@img/sharp-
|
|
162
|
-
"@img/sharp-
|
|
163
|
-
"@img/sharp-win32-
|
|
145
|
+
"@img/sharp-darwin-arm64": "0.34.0-rc.0",
|
|
146
|
+
"@img/sharp-darwin-x64": "0.34.0-rc.0",
|
|
147
|
+
"@img/sharp-libvips-darwin-arm64": "1.1.0-rc4",
|
|
148
|
+
"@img/sharp-libvips-darwin-x64": "1.1.0-rc4",
|
|
149
|
+
"@img/sharp-libvips-linux-arm": "1.1.0-rc4.1",
|
|
150
|
+
"@img/sharp-libvips-linux-arm64": "1.1.0-rc4",
|
|
151
|
+
"@img/sharp-libvips-linux-ppc64": "1.1.0-rc4",
|
|
152
|
+
"@img/sharp-libvips-linux-s390x": "1.1.0-rc4",
|
|
153
|
+
"@img/sharp-libvips-linux-x64": "1.1.0-rc4",
|
|
154
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0-rc4",
|
|
155
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.1.0-rc4",
|
|
156
|
+
"@img/sharp-linux-arm": "0.34.0-rc.0",
|
|
157
|
+
"@img/sharp-linux-arm64": "0.34.0-rc.0",
|
|
158
|
+
"@img/sharp-linux-s390x": "0.34.0-rc.0",
|
|
159
|
+
"@img/sharp-linux-x64": "0.34.0-rc.0",
|
|
160
|
+
"@img/sharp-linuxmusl-arm64": "0.34.0-rc.0",
|
|
161
|
+
"@img/sharp-linuxmusl-x64": "0.34.0-rc.0",
|
|
162
|
+
"@img/sharp-wasm32": "0.34.0-rc.0",
|
|
163
|
+
"@img/sharp-win32-ia32": "0.34.0-rc.0",
|
|
164
|
+
"@img/sharp-win32-x64": "0.34.0-rc.0"
|
|
164
165
|
},
|
|
165
166
|
"devDependencies": {
|
|
166
|
-
"@emnapi/runtime": "^1.
|
|
167
|
-
"@img/sharp-libvips-dev": "1.0
|
|
168
|
-
"@img/sharp-libvips-dev-wasm32": "1.0
|
|
169
|
-
"@img/sharp-libvips-win32-ia32": "1.0
|
|
170
|
-
"@img/sharp-libvips-win32-x64": "1.0
|
|
167
|
+
"@emnapi/runtime": "^1.3.1",
|
|
168
|
+
"@img/sharp-libvips-dev": "1.1.0-rc4",
|
|
169
|
+
"@img/sharp-libvips-dev-wasm32": "1.1.0-rc4",
|
|
170
|
+
"@img/sharp-libvips-win32-ia32": "1.1.0-rc4",
|
|
171
|
+
"@img/sharp-libvips-win32-x64": "1.1.0-rc4",
|
|
171
172
|
"@types/node": "*",
|
|
172
|
-
"async": "^3.2.5",
|
|
173
173
|
"cc": "^3.0.1",
|
|
174
|
-
"emnapi": "^1.
|
|
175
|
-
"exif-reader": "^2.0.
|
|
174
|
+
"emnapi": "^1.3.1",
|
|
175
|
+
"exif-reader": "^2.0.2",
|
|
176
176
|
"extract-zip": "^2.0.1",
|
|
177
177
|
"icc": "^3.0.0",
|
|
178
|
-
"jsdoc-to-markdown": "^
|
|
178
|
+
"jsdoc-to-markdown": "^9.1.1",
|
|
179
179
|
"license-checker": "^25.0.1",
|
|
180
|
-
"mocha": "^
|
|
181
|
-
"node-addon-api": "^8.1
|
|
182
|
-
"nyc": "^17.
|
|
180
|
+
"mocha": "^11.1.0",
|
|
181
|
+
"node-addon-api": "^8.3.1",
|
|
182
|
+
"nyc": "^17.1.0",
|
|
183
183
|
"prebuild": "^13.0.1",
|
|
184
184
|
"semistandard": "^17.0.0",
|
|
185
|
-
"tar-fs": "^3.0.
|
|
186
|
-
"tsd": "^0.31.
|
|
185
|
+
"tar-fs": "^3.0.8",
|
|
186
|
+
"tsd": "^0.31.2"
|
|
187
187
|
},
|
|
188
188
|
"license": "Apache-2.0",
|
|
189
189
|
"engines": {
|
|
190
190
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
191
191
|
},
|
|
192
192
|
"config": {
|
|
193
|
-
"libvips": ">=8.
|
|
193
|
+
"libvips": ">=8.16.1"
|
|
194
194
|
},
|
|
195
195
|
"funding": {
|
|
196
196
|
"url": "https://opencollective.com/libvips"
|
package/src/binding.gyp
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
'sharp_libvips_lib_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsLibDir()")'
|
|
13
13
|
},
|
|
14
14
|
'targets': [{
|
|
15
|
-
'target_name': 'libvips-cpp',
|
|
15
|
+
'target_name': 'libvips-cpp-<(vips_version)',
|
|
16
16
|
'conditions': [
|
|
17
17
|
['OS == "win"', {
|
|
18
18
|
# Build libvips C++ binding for Windows due to MSVC std library ABI changes
|
|
19
19
|
'type': 'shared_library',
|
|
20
20
|
'defines': [
|
|
21
|
-
'
|
|
21
|
+
'_VIPS_PUBLIC=__declspec(dllexport)',
|
|
22
22
|
'_ALLOW_KEYWORD_MACROS'
|
|
23
23
|
],
|
|
24
24
|
'sources': [
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
'Release': {
|
|
46
46
|
'msvs_settings': {
|
|
47
47
|
'VCCLCompilerTool': {
|
|
48
|
+
"AdditionalOptions": [
|
|
49
|
+
"/std:c++17"
|
|
50
|
+
],
|
|
48
51
|
'ExceptionHandling': 1,
|
|
49
52
|
'Optimization': 1,
|
|
50
53
|
'WholeProgramOptimization': 'true'
|
|
@@ -83,7 +86,7 @@
|
|
|
83
86
|
],
|
|
84
87
|
'dependencies': [
|
|
85
88
|
'<!(node -p "require(\'node-addon-api\').gyp")',
|
|
86
|
-
'libvips-cpp'
|
|
89
|
+
'libvips-cpp-<(vips_version)'
|
|
87
90
|
],
|
|
88
91
|
'variables': {
|
|
89
92
|
'conditions': [
|
|
@@ -149,7 +152,7 @@
|
|
|
149
152
|
['OS == "mac"', {
|
|
150
153
|
'link_settings': {
|
|
151
154
|
'libraries': [
|
|
152
|
-
'libvips-cpp.
|
|
155
|
+
'libvips-cpp.<(vips_version).dylib'
|
|
153
156
|
]
|
|
154
157
|
},
|
|
155
158
|
'xcode_settings': {
|
|
@@ -169,9 +172,10 @@
|
|
|
169
172
|
],
|
|
170
173
|
'link_settings': {
|
|
171
174
|
'libraries': [
|
|
172
|
-
'-l:libvips-cpp.so
|
|
175
|
+
'-l:libvips-cpp.so.<(vips_version)'
|
|
173
176
|
],
|
|
174
177
|
'ldflags': [
|
|
178
|
+
'-lstdc++fs',
|
|
175
179
|
'-Wl,-s',
|
|
176
180
|
'-Wl,--disable-new-dtags',
|
|
177
181
|
'-Wl,-z,nodelete',
|
|
@@ -207,14 +211,14 @@
|
|
|
207
211
|
}]
|
|
208
212
|
],
|
|
209
213
|
'cflags_cc': [
|
|
210
|
-
'-std=c++
|
|
214
|
+
'-std=c++17',
|
|
211
215
|
'-fexceptions',
|
|
212
216
|
'-Wall',
|
|
213
217
|
'-Os'
|
|
214
218
|
],
|
|
215
219
|
'xcode_settings': {
|
|
216
|
-
'CLANG_CXX_LANGUAGE_STANDARD': 'c++
|
|
217
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.
|
|
220
|
+
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
|
|
221
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.15',
|
|
218
222
|
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
|
219
223
|
'GCC_ENABLE_CPP_RTTI': 'YES',
|
|
220
224
|
'OTHER_CPLUSPLUSFLAGS': [
|
|
@@ -234,6 +238,9 @@
|
|
|
234
238
|
['OS == "win"', {
|
|
235
239
|
'msvs_settings': {
|
|
236
240
|
'VCCLCompilerTool': {
|
|
241
|
+
"AdditionalOptions": [
|
|
242
|
+
"/std:c++17"
|
|
243
|
+
],
|
|
237
244
|
'ExceptionHandling': 1,
|
|
238
245
|
'Optimization': 1,
|
|
239
246
|
'WholeProgramOptimization': 'true'
|