sharp 0.27.1 → 0.27.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/install/libvips.js +8 -0
- package/lib/constructor.js +1 -1
- package/lib/libvips.js +13 -1
- package/lib/output.js +18 -18
- package/lib/utility.js +4 -8
- package/package.json +4 -4
- package/src/common.cc +1 -6
- package/src/operations.cc +1 -1
package/install/libvips.js
CHANGED
|
@@ -74,6 +74,9 @@ try {
|
|
|
74
74
|
if (arch === 'ia32' && !platformAndArch.startsWith('win32')) {
|
|
75
75
|
throw new Error(`Intel Architecture 32-bit systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
76
76
|
}
|
|
77
|
+
if (platformAndArch === 'darwin-arm64') {
|
|
78
|
+
throw new Error("Please run 'brew install vips' to install libvips on Apple M1 (ARM64) systems");
|
|
79
|
+
}
|
|
77
80
|
if (platformAndArch === 'freebsd-x64' || platformAndArch === 'openbsd-x64' || platformAndArch === 'sunos-x64') {
|
|
78
81
|
throw new Error(`BSD/SunOS systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
79
82
|
}
|
|
@@ -82,6 +85,11 @@ try {
|
|
|
82
85
|
throw new Error(`Use with glibc ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
88
|
+
if (detectLibc.family === detectLibc.MUSL && detectLibc.version) {
|
|
89
|
+
if (!semver.satisfies(detectLibc.version, '>=1.1.24 <1.2.0')) {
|
|
90
|
+
throw new Error(`Use with musl ${detectLibc.version} requires manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
85
93
|
|
|
86
94
|
const supportedNodeVersion = process.env.npm_package_engines_node || require('../package.json').engines.node;
|
|
87
95
|
if (!semver.satisfies(process.versions.node, supportedNodeVersion)) {
|
package/lib/constructor.js
CHANGED
|
@@ -117,7 +117,7 @@ const debuglog = util.debuglog('sharp');
|
|
|
117
117
|
* sigma: 30
|
|
118
118
|
* }
|
|
119
119
|
* }
|
|
120
|
-
* }.toFile('noise.png');
|
|
120
|
+
* }).toFile('noise.png');
|
|
121
121
|
*
|
|
122
122
|
* @param {(Buffer|Uint8Array|Uint8ClampedArray|string)} [input] - if present, can be
|
|
123
123
|
* a Buffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data, or
|
package/lib/libvips.js
CHANGED
|
@@ -37,6 +37,15 @@ const cachePath = function () {
|
|
|
37
37
|
return libvipsCachePath;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const isRosetta = function () {
|
|
41
|
+
/* istanbul ignore next */
|
|
42
|
+
if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
43
|
+
const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;
|
|
44
|
+
return (translated || '').trim() === 'sysctl.proc_translated: 1';
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
|
|
40
49
|
const globalLibvipsVersion = function () {
|
|
41
50
|
if (process.platform !== 'win32') {
|
|
42
51
|
const globalLibvipsVersion = spawnSync(`PKG_CONFIG_PATH="${pkgConfigPath()}" pkg-config --modversion vips-cpp`, spawnSyncOptions).stdout;
|
|
@@ -82,7 +91,10 @@ const useGlobalLibvips = function () {
|
|
|
82
91
|
if (Boolean(env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
|
|
83
92
|
return false;
|
|
84
93
|
}
|
|
85
|
-
|
|
94
|
+
/* istanbul ignore next */
|
|
95
|
+
if (isRosetta()) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
86
98
|
const globalVipsVersion = globalLibvipsVersion();
|
|
87
99
|
return !!globalVipsVersion && /* istanbul ignore next */
|
|
88
100
|
semver.gte(globalVipsVersion, minimumLibvipsVersion);
|
package/lib/output.js
CHANGED
|
@@ -16,6 +16,8 @@ const formats = new Map([
|
|
|
16
16
|
['gif', 'gif']
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
|
+
const errMagickSave = new Error('GIF output requires libvips with support for ImageMagick');
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* Write output image data to a file.
|
|
21
23
|
*
|
|
@@ -47,25 +49,23 @@ const formats = new Map([
|
|
|
47
49
|
* @throws {Error} Invalid parameters
|
|
48
50
|
*/
|
|
49
51
|
function toFile (fileOut, callback) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
let err;
|
|
53
|
+
if (!is.string(fileOut)) {
|
|
54
|
+
err = new Error('Missing output file path');
|
|
55
|
+
} else if (this.options.input.file === fileOut) {
|
|
56
|
+
err = new Error('Cannot use same file for input and output');
|
|
57
|
+
} else if (this.options.formatOut === 'input' && fileOut.toLowerCase().endsWith('.gif') && !this.constructor.format.magick.output.file) {
|
|
58
|
+
err = errMagickSave;
|
|
59
|
+
}
|
|
60
|
+
if (err) {
|
|
52
61
|
if (is.fn(callback)) {
|
|
53
|
-
callback(
|
|
62
|
+
callback(err);
|
|
54
63
|
} else {
|
|
55
|
-
return Promise.reject(
|
|
64
|
+
return Promise.reject(err);
|
|
56
65
|
}
|
|
57
66
|
} else {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (is.fn(callback)) {
|
|
61
|
-
callback(errOutputIsInput);
|
|
62
|
-
} else {
|
|
63
|
-
return Promise.reject(errOutputIsInput);
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
this.options.fileOut = fileOut;
|
|
67
|
-
return this._pipeline(callback);
|
|
68
|
-
}
|
|
67
|
+
this.options.fileOut = fileOut;
|
|
68
|
+
return this._pipeline(callback);
|
|
69
69
|
}
|
|
70
70
|
return this;
|
|
71
71
|
}
|
|
@@ -188,7 +188,7 @@ function withMetadata (options) {
|
|
|
188
188
|
* @throws {Error} unsupported format or options
|
|
189
189
|
*/
|
|
190
190
|
function toFormat (format, options) {
|
|
191
|
-
const actualFormat = formats.get(is.object(format) && is.string(format.id) ? format.id : format);
|
|
191
|
+
const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());
|
|
192
192
|
if (!actualFormat) {
|
|
193
193
|
throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);
|
|
194
194
|
}
|
|
@@ -426,7 +426,7 @@ function webp (options) {
|
|
|
426
426
|
/* istanbul ignore next */
|
|
427
427
|
function gif (options) {
|
|
428
428
|
if (!this.constructor.format.magick.output.buffer) {
|
|
429
|
-
throw
|
|
429
|
+
throw errMagickSave;
|
|
430
430
|
}
|
|
431
431
|
trySetAnimationOptions(options, this.options);
|
|
432
432
|
return this._updateFormatOut('gif', options);
|
|
@@ -582,7 +582,7 @@ function tiff (options) {
|
|
|
582
582
|
* @param {Object} [options] - output options
|
|
583
583
|
* @param {number} [options.quality=50] - quality, integer 1-100
|
|
584
584
|
* @param {boolean} [options.lossless=false] - use lossless compression
|
|
585
|
-
* @param {
|
|
585
|
+
* @param {number} [options.speed=5] - CPU effort vs file size, 0 (slowest/smallest) to 8 (fastest/largest)
|
|
586
586
|
* @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling, requires libvips v8.11.0
|
|
587
587
|
* @returns {Sharp}
|
|
588
588
|
* @throws {Error} Invalid options
|
package/lib/utility.js
CHANGED
|
@@ -157,14 +157,10 @@ simd(true);
|
|
|
157
157
|
* @private
|
|
158
158
|
*/
|
|
159
159
|
module.exports = function (Sharp) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
simd
|
|
165
|
-
].forEach(function (f) {
|
|
166
|
-
Sharp[f.name] = f;
|
|
167
|
-
});
|
|
160
|
+
Sharp.cache = cache;
|
|
161
|
+
Sharp.concurrency = concurrency;
|
|
162
|
+
Sharp.counters = counters;
|
|
163
|
+
Sharp.simd = simd;
|
|
168
164
|
Sharp.format = format;
|
|
169
165
|
Sharp.interpolators = interpolators;
|
|
170
166
|
Sharp.versions = versions;
|
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, AVIF and TIFF images",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.2",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)",
|
|
81
81
|
"clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
|
|
82
82
|
"test": "semistandard && cpplint && npm run test-unit && npm run test-licensing",
|
|
83
|
-
"test-unit": "nyc --reporter=lcov --branches=99 mocha --
|
|
83
|
+
"test-unit": "nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js",
|
|
84
84
|
"test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"",
|
|
85
85
|
"test-coverage": "./test/coverage/report.sh",
|
|
86
86
|
"test-leak": "./test/leak/leak.sh",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"detect-libc": "^1.0.3",
|
|
123
123
|
"node-addon-api": "^3.1.0",
|
|
124
124
|
"npmlog": "^4.1.2",
|
|
125
|
-
"prebuild-install": "^6.0.
|
|
125
|
+
"prebuild-install": "^6.0.1",
|
|
126
126
|
"semver": "^7.3.4",
|
|
127
127
|
"simple-get": "^4.0.0",
|
|
128
128
|
"tar-fs": "^2.1.1",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"exif-reader": "^1.0.3",
|
|
137
137
|
"icc": "^2.0.0",
|
|
138
138
|
"license-checker": "^25.0.1",
|
|
139
|
-
"mocha": "^8.
|
|
139
|
+
"mocha": "^8.3.0",
|
|
140
140
|
"mock-fs": "^4.13.0",
|
|
141
141
|
"nyc": "^15.1.0",
|
|
142
142
|
"prebuild": "^10.0.1",
|
package/src/common.cc
CHANGED
|
@@ -421,12 +421,7 @@ namespace sharp {
|
|
|
421
421
|
Uses colour space interpretation with number of channels to guess this.
|
|
422
422
|
*/
|
|
423
423
|
bool HasAlpha(VImage image) {
|
|
424
|
-
|
|
425
|
-
VipsInterpretation const interpretation = image.interpretation();
|
|
426
|
-
return (
|
|
427
|
-
(bands == 2 && interpretation == VIPS_INTERPRETATION_B_W) ||
|
|
428
|
-
(bands == 4 && interpretation != VIPS_INTERPRETATION_CMYK) ||
|
|
429
|
-
(bands == 5 && interpretation == VIPS_INTERPRETATION_CMYK));
|
|
424
|
+
return image.has_alpha();
|
|
430
425
|
}
|
|
431
426
|
|
|
432
427
|
/*
|
package/src/operations.cc
CHANGED
|
@@ -149,8 +149,8 @@ namespace sharp {
|
|
|
149
149
|
*/
|
|
150
150
|
VImage Recomb(VImage image, std::unique_ptr<double[]> const &matrix) {
|
|
151
151
|
double *m = matrix.get();
|
|
152
|
+
image = image.colourspace(VIPS_INTERPRETATION_sRGB);
|
|
152
153
|
return image
|
|
153
|
-
.colourspace(VIPS_INTERPRETATION_sRGB)
|
|
154
154
|
.recomb(image.bands() == 3
|
|
155
155
|
? VImage::new_from_memory(
|
|
156
156
|
m, 9 * sizeof(double), 3, 3, 1, VIPS_FORMAT_DOUBLE
|