sharp 0.34.4 → 0.34.5-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/install/build.js +38 -0
- package/install/check.js +7 -34
- package/lib/channel.js +6 -6
- package/lib/colour.js +12 -9
- package/lib/composite.js +8 -8
- package/lib/constructor.js +11 -7
- package/lib/index.d.ts +13 -6
- package/lib/index.js +4 -4
- package/lib/input.js +12 -14
- package/lib/is.js +19 -45
- package/lib/libvips.js +25 -23
- package/lib/operation.js +9 -11
- package/lib/output.js +26 -15
- package/lib/resize.js +5 -5
- package/lib/sharp.js +7 -8
- package/lib/utility.js +9 -9
- package/package.json +47 -59
- package/src/common.cc +11 -7
- package/src/common.h +9 -6
- package/src/metadata.cc +15 -11
- package/src/metadata.h +5 -2
- package/src/operations.cc +6 -4
- package/src/operations.h +5 -2
- package/src/pipeline.cc +35 -34
- package/src/pipeline.h +9 -3
- package/src/sharp.cc +10 -8
- package/src/stats.cc +8 -5
- package/src/stats.h +6 -3
- package/src/utilities.cc +8 -6
- package/src/utilities.h +4 -2
package/lib/libvips.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
const { spawnSync } = require('node:child_process');
|
|
7
7
|
const { createHash } = require('node:crypto');
|
|
@@ -12,13 +12,13 @@ const detectLibc = require('detect-libc');
|
|
|
12
12
|
|
|
13
13
|
const { config, engines, optionalDependencies } = require('../package.json');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/* node:coverage ignore next */
|
|
16
|
+
const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips;
|
|
17
17
|
const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version;
|
|
18
18
|
|
|
19
19
|
const prebuiltPlatforms = [
|
|
20
20
|
'darwin-arm64', 'darwin-x64',
|
|
21
|
-
'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-s390x', 'linux-x64',
|
|
21
|
+
'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-x64',
|
|
22
22
|
'linuxmusl-arm64', 'linuxmusl-x64',
|
|
23
23
|
'win32-arm64', 'win32-ia32', 'win32-x64'
|
|
24
24
|
];
|
|
@@ -36,17 +36,16 @@ const log = (item) => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
/*
|
|
39
|
+
/* node:coverage ignore next */
|
|
40
40
|
const runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : '';
|
|
41
41
|
|
|
42
42
|
const runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`;
|
|
43
43
|
|
|
44
|
-
/* istanbul ignore next */
|
|
45
44
|
const buildPlatformArch = () => {
|
|
45
|
+
/* node:coverage ignore next 3 */
|
|
46
46
|
if (isEmscripten()) {
|
|
47
47
|
return 'wasm32';
|
|
48
48
|
}
|
|
49
|
-
/* eslint camelcase: ["error", { allow: ["^npm_config_"] }] */
|
|
50
49
|
const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;
|
|
51
50
|
const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc();
|
|
52
51
|
return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;
|
|
@@ -56,19 +55,19 @@ const buildSharpLibvipsIncludeDir = () => {
|
|
|
56
55
|
try {
|
|
57
56
|
return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`);
|
|
58
57
|
} catch {
|
|
58
|
+
/* node:coverage ignore next 5 */
|
|
59
59
|
try {
|
|
60
60
|
return require('@img/sharp-libvips-dev/include');
|
|
61
61
|
} catch {}
|
|
62
62
|
}
|
|
63
|
-
/* istanbul ignore next */
|
|
64
63
|
return '';
|
|
65
64
|
};
|
|
66
65
|
|
|
67
66
|
const buildSharpLibvipsCPlusPlusDir = () => {
|
|
67
|
+
/* node:coverage ignore next 4 */
|
|
68
68
|
try {
|
|
69
69
|
return require('@img/sharp-libvips-dev/cplusplus');
|
|
70
70
|
} catch {}
|
|
71
|
-
/* istanbul ignore next */
|
|
72
71
|
return '';
|
|
73
72
|
};
|
|
74
73
|
|
|
@@ -76,16 +75,17 @@ const buildSharpLibvipsLibDir = () => {
|
|
|
76
75
|
try {
|
|
77
76
|
return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`);
|
|
78
77
|
} catch {
|
|
78
|
+
/* node:coverage ignore next 5 */
|
|
79
79
|
try {
|
|
80
80
|
return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);
|
|
81
81
|
} catch {}
|
|
82
82
|
}
|
|
83
|
-
/* istanbul ignore next */
|
|
84
83
|
return '';
|
|
85
84
|
};
|
|
86
85
|
|
|
86
|
+
/* node:coverage disable */
|
|
87
|
+
|
|
87
88
|
const isUnsupportedNodeRuntime = () => {
|
|
88
|
-
/* istanbul ignore next */
|
|
89
89
|
if (process.release?.name === 'node' && process.versions) {
|
|
90
90
|
if (!semverSatisfies(process.versions.node, engines.node)) {
|
|
91
91
|
return { found: process.versions.node, expected: engines.node };
|
|
@@ -93,14 +93,12 @@ const isUnsupportedNodeRuntime = () => {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
/* istanbul ignore next */
|
|
97
96
|
const isEmscripten = () => {
|
|
98
97
|
const { CC } = process.env;
|
|
99
|
-
return Boolean(CC
|
|
98
|
+
return Boolean(CC?.endsWith('/emcc'));
|
|
100
99
|
};
|
|
101
100
|
|
|
102
101
|
const isRosetta = () => {
|
|
103
|
-
/* istanbul ignore next */
|
|
104
102
|
if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
105
103
|
const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;
|
|
106
104
|
return (translated || '').trim() === 'sysctl.proc_translated: 1';
|
|
@@ -108,6 +106,8 @@ const isRosetta = () => {
|
|
|
108
106
|
return false;
|
|
109
107
|
};
|
|
110
108
|
|
|
109
|
+
/* node:coverage enable */
|
|
110
|
+
|
|
111
111
|
const sha512 = (s) => createHash('sha512').update(s).digest('hex');
|
|
112
112
|
|
|
113
113
|
const yarnLocator = () => {
|
|
@@ -121,7 +121,8 @@ const yarnLocator = () => {
|
|
|
121
121
|
return '';
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
/*
|
|
124
|
+
/* node:coverage disable */
|
|
125
|
+
|
|
125
126
|
const spawnRebuild = () =>
|
|
126
127
|
spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {
|
|
127
128
|
...spawnSyncOptions,
|
|
@@ -137,16 +138,17 @@ const globalLibvipsVersion = () => {
|
|
|
137
138
|
PKG_CONFIG_PATH: pkgConfigPath()
|
|
138
139
|
}
|
|
139
140
|
}).stdout;
|
|
140
|
-
/* istanbul ignore next */
|
|
141
141
|
return (globalLibvipsVersion || '').trim();
|
|
142
142
|
} else {
|
|
143
143
|
return '';
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
/*
|
|
147
|
+
/* node:coverage enable */
|
|
148
|
+
|
|
148
149
|
const pkgConfigPath = () => {
|
|
149
150
|
if (process.platform !== 'win32') {
|
|
151
|
+
/* node:coverage ignore next 4 */
|
|
150
152
|
const brewPkgConfigPath = spawnSync(
|
|
151
153
|
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
|
|
152
154
|
spawnSyncOptions
|
|
@@ -178,13 +180,13 @@ const useGlobalLibvips = (logger) => {
|
|
|
178
180
|
if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
|
|
179
181
|
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger);
|
|
180
182
|
}
|
|
181
|
-
/*
|
|
183
|
+
/* node:coverage ignore next 3 */
|
|
182
184
|
if (isRosetta()) {
|
|
183
185
|
return skipSearch(false, 'Rosetta', logger);
|
|
184
186
|
}
|
|
185
187
|
const globalVipsVersion = globalLibvipsVersion();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
/* node:coverage ignore next */
|
|
189
|
+
return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);
|
|
188
190
|
};
|
|
189
191
|
|
|
190
192
|
module.exports = {
|
package/lib/operation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
const is = require('./is');
|
|
7
7
|
|
|
@@ -239,7 +239,7 @@ function affine (matrix, options) {
|
|
|
239
239
|
* When a `sigma` is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
|
|
240
240
|
* Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
|
|
241
241
|
*
|
|
242
|
-
* See {@link https://www.libvips.org/API/current/
|
|
242
|
+
* See {@link https://www.libvips.org/API/current/method.Image.sharpen.html libvips sharpen} operation.
|
|
243
243
|
*
|
|
244
244
|
* @example
|
|
245
245
|
* const data = await sharp(input).sharpen().toBuffer();
|
|
@@ -485,7 +485,7 @@ function erode (width) {
|
|
|
485
485
|
/**
|
|
486
486
|
* Merge alpha transparency channel, if any, with a background, then remove the alpha channel.
|
|
487
487
|
*
|
|
488
|
-
* See also {@link /api-channel#removealpha
|
|
488
|
+
* See also {@link /api-channel#removealpha removeAlpha}.
|
|
489
489
|
*
|
|
490
490
|
* @example
|
|
491
491
|
* await sharp(rgbaInput)
|
|
@@ -660,7 +660,7 @@ function normalize (options) {
|
|
|
660
660
|
|
|
661
661
|
/**
|
|
662
662
|
* Perform contrast limiting adaptive histogram equalization
|
|
663
|
-
* {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE
|
|
663
|
+
* {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE CLAHE}.
|
|
664
664
|
*
|
|
665
665
|
* This will, in general, enhance the clarity of the image by bringing out darker details.
|
|
666
666
|
*
|
|
@@ -742,9 +742,7 @@ function convolve (kernel) {
|
|
|
742
742
|
}
|
|
743
743
|
// Default scale is sum of kernel values
|
|
744
744
|
if (!is.integer(kernel.scale)) {
|
|
745
|
-
kernel.scale = kernel.kernel.reduce(
|
|
746
|
-
return a + b;
|
|
747
|
-
}, 0);
|
|
745
|
+
kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);
|
|
748
746
|
}
|
|
749
747
|
// Clip scale to a minimum value of 1
|
|
750
748
|
if (kernel.scale < 1) {
|
|
@@ -989,7 +987,7 @@ function modulate (options) {
|
|
|
989
987
|
* @module Sharp
|
|
990
988
|
* @private
|
|
991
989
|
*/
|
|
992
|
-
module.exports =
|
|
990
|
+
module.exports = (Sharp) => {
|
|
993
991
|
Object.assign(Sharp.prototype, {
|
|
994
992
|
autoOrient,
|
|
995
993
|
rotate,
|
package/lib/output.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
const path = require('node:path');
|
|
7
7
|
const is = require('./is');
|
|
@@ -43,7 +43,7 @@ const bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math
|
|
|
43
43
|
* Note that raw pixel data is only supported for buffer output.
|
|
44
44
|
*
|
|
45
45
|
* By default all metadata will be removed, which includes EXIF-based orientation.
|
|
46
|
-
* See {@link #withmetadata
|
|
46
|
+
* See {@link #withmetadata withMetadata} for control over this.
|
|
47
47
|
*
|
|
48
48
|
* The caller is responsible for ensuring directory structures and permissions exist.
|
|
49
49
|
*
|
|
@@ -97,12 +97,12 @@ function toFile (fileOut, callback) {
|
|
|
97
97
|
* Write output to a Buffer.
|
|
98
98
|
* JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
|
|
99
99
|
*
|
|
100
|
-
* Use {@link #toformat
|
|
100
|
+
* Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.
|
|
101
101
|
*
|
|
102
102
|
* If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
|
|
103
103
|
*
|
|
104
104
|
* By default all metadata will be removed, which includes EXIF-based orientation.
|
|
105
|
-
* See {@link #withmetadata
|
|
105
|
+
* See {@link #withmetadata withMetadata} for control over this.
|
|
106
106
|
*
|
|
107
107
|
* `callback`, if present, gets three arguments `(err, data, info)` where:
|
|
108
108
|
* - `err` is an error, if any.
|
|
@@ -256,7 +256,7 @@ function withExifMerge (exif) {
|
|
|
256
256
|
/**
|
|
257
257
|
* Keep ICC profile from the input image in the output image.
|
|
258
258
|
*
|
|
259
|
-
*
|
|
259
|
+
* When input and output colour spaces differ, use with {@link /api-colour/#tocolourspace toColourspace} and optionally {@link /api-colour/#pipelinecolourspace pipelineColourspace}.
|
|
260
260
|
*
|
|
261
261
|
* @since 0.33.0
|
|
262
262
|
*
|
|
@@ -265,6 +265,13 @@ function withExifMerge (exif) {
|
|
|
265
265
|
* .keepIccProfile()
|
|
266
266
|
* .toBuffer();
|
|
267
267
|
*
|
|
268
|
+
* @example
|
|
269
|
+
* const cmykOutputWithIccProfile = await sharp(cmykInputWithIccProfile)
|
|
270
|
+
* .pipelineColourspace('cmyk')
|
|
271
|
+
* .toColourspace('cmyk')
|
|
272
|
+
* .keepIccProfile()
|
|
273
|
+
* .toBuffer();
|
|
274
|
+
*
|
|
268
275
|
* @returns {Sharp}
|
|
269
276
|
*/
|
|
270
277
|
function keepIccProfile () {
|
|
@@ -565,7 +572,7 @@ function jpeg (options) {
|
|
|
565
572
|
* Set `palette` to `true` for slower, indexed PNG output.
|
|
566
573
|
*
|
|
567
574
|
* For 16 bits per pixel output, convert to `rgb16` via
|
|
568
|
-
* {@link /api-colour
|
|
575
|
+
* {@link /api-colour/#tocolourspace toColourspace}.
|
|
569
576
|
*
|
|
570
577
|
* @example
|
|
571
578
|
* // Convert any input to full colour PNG output
|
|
@@ -845,13 +852,12 @@ function gif (options) {
|
|
|
845
852
|
return this._updateFormatOut('gif', options);
|
|
846
853
|
}
|
|
847
854
|
|
|
848
|
-
/* istanbul ignore next */
|
|
849
855
|
/**
|
|
850
856
|
* Use these JP2 options for output image.
|
|
851
857
|
*
|
|
852
858
|
* Requires libvips compiled with support for OpenJPEG.
|
|
853
859
|
* The prebuilt binaries do not include this - see
|
|
854
|
-
* {@link
|
|
860
|
+
* {@link /install#custom-libvips installing a custom libvips}.
|
|
855
861
|
*
|
|
856
862
|
* @example
|
|
857
863
|
* // Convert any input to lossless JP2 output
|
|
@@ -880,6 +886,7 @@ function gif (options) {
|
|
|
880
886
|
* @throws {Error} Invalid options
|
|
881
887
|
*/
|
|
882
888
|
function jp2 (options) {
|
|
889
|
+
/* node:coverage ignore next 41 */
|
|
883
890
|
if (!this.constructor.format.jp2k.output.buffer) {
|
|
884
891
|
throw errJp2Save();
|
|
885
892
|
}
|
|
@@ -959,7 +966,7 @@ function trySetAnimationOptions (source, target) {
|
|
|
959
966
|
/**
|
|
960
967
|
* Use these TIFF options for output image.
|
|
961
968
|
*
|
|
962
|
-
* The `density` can be set in pixels/inch via {@link #withmetadata
|
|
969
|
+
* The `density` can be set in pixels/inch via {@link #withmetadata withMetadata}
|
|
963
970
|
* instead of providing `xres` and `yres` in pixels/mm.
|
|
964
971
|
*
|
|
965
972
|
* @example
|
|
@@ -976,6 +983,7 @@ function trySetAnimationOptions (source, target) {
|
|
|
976
983
|
* @param {number} [options.quality=80] - quality, integer 1-100
|
|
977
984
|
* @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
|
|
978
985
|
* @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
|
|
986
|
+
* @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)
|
|
979
987
|
* @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
|
|
980
988
|
* @param {boolean} [options.pyramid=false] - write an image pyramid
|
|
981
989
|
* @param {boolean} [options.tile=false] - write a tiled tiff
|
|
@@ -1054,6 +1062,10 @@ function tiff (options) {
|
|
|
1054
1062
|
throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
|
|
1055
1063
|
}
|
|
1056
1064
|
}
|
|
1065
|
+
// bigtiff
|
|
1066
|
+
if (is.defined(options.bigtiff)) {
|
|
1067
|
+
this._setBooleanOption('tiffBigtiff', options.bigtiff);
|
|
1068
|
+
}
|
|
1057
1069
|
// predictor
|
|
1058
1070
|
if (is.defined(options.predictor)) {
|
|
1059
1071
|
if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
|
|
@@ -1189,7 +1201,7 @@ function heif (options) {
|
|
|
1189
1201
|
*
|
|
1190
1202
|
* Requires libvips compiled with support for libjxl.
|
|
1191
1203
|
* The prebuilt binaries do not include this - see
|
|
1192
|
-
* {@link
|
|
1204
|
+
* {@link /install/#custom-libvips installing a custom libvips}.
|
|
1193
1205
|
*
|
|
1194
1206
|
* @since 0.31.3
|
|
1195
1207
|
*
|
|
@@ -1502,7 +1514,6 @@ function _setBooleanOption (key, val) {
|
|
|
1502
1514
|
* @private
|
|
1503
1515
|
*/
|
|
1504
1516
|
function _read () {
|
|
1505
|
-
/* istanbul ignore else */
|
|
1506
1517
|
if (!this.options.streamOut) {
|
|
1507
1518
|
this.options.streamOut = true;
|
|
1508
1519
|
const stack = Error();
|
|
@@ -1619,7 +1630,7 @@ function _pipeline (callback, stack) {
|
|
|
1619
1630
|
* @module Sharp
|
|
1620
1631
|
* @private
|
|
1621
1632
|
*/
|
|
1622
|
-
module.exports =
|
|
1633
|
+
module.exports = (Sharp) => {
|
|
1623
1634
|
Object.assign(Sharp.prototype, {
|
|
1624
1635
|
// Public
|
|
1625
1636
|
toFile,
|
package/lib/resize.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
const is = require('./is');
|
|
7
7
|
|
|
@@ -579,7 +579,7 @@ function trim (options) {
|
|
|
579
579
|
* @module Sharp
|
|
580
580
|
* @private
|
|
581
581
|
*/
|
|
582
|
-
module.exports =
|
|
582
|
+
module.exports = (Sharp) => {
|
|
583
583
|
Object.assign(Sharp.prototype, {
|
|
584
584
|
resize,
|
|
585
585
|
extend,
|
package/lib/sharp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
// Inspects the runtime environment and exports the relevant sharp.node binary
|
|
7
7
|
|
|
@@ -17,6 +17,8 @@ const paths = [
|
|
|
17
17
|
'@img/sharp-wasm32/sharp.node'
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
+
/* node:coverage disable */
|
|
21
|
+
|
|
20
22
|
let path, sharp;
|
|
21
23
|
const errors = [];
|
|
22
24
|
for (path of paths) {
|
|
@@ -24,12 +26,10 @@ for (path of paths) {
|
|
|
24
26
|
sharp = require(path);
|
|
25
27
|
break;
|
|
26
28
|
} catch (err) {
|
|
27
|
-
/* istanbul ignore next */
|
|
28
29
|
errors.push(err);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
/* istanbul ignore next */
|
|
33
33
|
if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {
|
|
34
34
|
const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
|
|
35
35
|
err.code = 'Unsupported CPU';
|
|
@@ -37,7 +37,6 @@ if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2())
|
|
|
37
37
|
sharp = null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/* istanbul ignore next */
|
|
41
40
|
if (sharp) {
|
|
42
41
|
module.exports = sharp;
|
|
43
42
|
} else {
|
|
@@ -88,7 +87,7 @@ if (sharp) {
|
|
|
88
87
|
` Found ${libcFound}`,
|
|
89
88
|
` Requires ${libcRequires}`
|
|
90
89
|
);
|
|
91
|
-
} catch (
|
|
90
|
+
} catch (_errEngines) {}
|
|
92
91
|
}
|
|
93
92
|
if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
|
|
94
93
|
help.push(
|
package/lib/utility.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
5
|
|
|
6
6
|
const events = require('node:events');
|
|
7
7
|
const detectLibc = require('detect-libc');
|
|
@@ -57,7 +57,7 @@ const interpolators = {
|
|
|
57
57
|
let versions = {
|
|
58
58
|
vips: libvipsVersion.semver
|
|
59
59
|
};
|
|
60
|
-
/*
|
|
60
|
+
/* node:coverage ignore next 15 */
|
|
61
61
|
if (!libvipsVersion.isGlobal) {
|
|
62
62
|
if (!libvipsVersion.isWasm) {
|
|
63
63
|
try {
|
|
@@ -75,7 +75,7 @@ if (!libvipsVersion.isGlobal) {
|
|
|
75
75
|
}
|
|
76
76
|
versions.sharp = require('../package.json').version;
|
|
77
77
|
|
|
78
|
-
/*
|
|
78
|
+
/* node:coverage ignore next 5 */
|
|
79
79
|
if (versions.heif && format.heif) {
|
|
80
80
|
// Prebuilt binaries provide AV1
|
|
81
81
|
format.heif.input.fileSuffix = ['.avif'];
|
|
@@ -136,7 +136,7 @@ cache(true);
|
|
|
136
136
|
* and these are independent of the value set here.
|
|
137
137
|
*
|
|
138
138
|
* :::note
|
|
139
|
-
* Further {@link /performance
|
|
139
|
+
* Further {@link /performance/ control over performance} is available.
|
|
140
140
|
* :::
|
|
141
141
|
*
|
|
142
142
|
* @example
|
|
@@ -150,7 +150,7 @@ cache(true);
|
|
|
150
150
|
function concurrency (concurrency) {
|
|
151
151
|
return sharp.concurrency(is.integer(concurrency) ? concurrency : null);
|
|
152
152
|
}
|
|
153
|
-
/*
|
|
153
|
+
/* node:coverage ignore next 7 */
|
|
154
154
|
if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
|
|
155
155
|
// Reduce default concurrency to 1 when using glibc memory allocator
|
|
156
156
|
sharp.concurrency(1);
|
|
@@ -277,7 +277,7 @@ function unblock (options) {
|
|
|
277
277
|
* @module Sharp
|
|
278
278
|
* @private
|
|
279
279
|
*/
|
|
280
|
-
module.exports =
|
|
280
|
+
module.exports = (Sharp) => {
|
|
281
281
|
Sharp.cache = cache;
|
|
282
282
|
Sharp.concurrency = concurrency;
|
|
283
283
|
Sharp.counters = counters;
|
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.34.
|
|
4
|
+
"version": "0.34.5-rc.1",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -92,14 +92,16 @@
|
|
|
92
92
|
"Don Denton <don@happycollision.com>"
|
|
93
93
|
],
|
|
94
94
|
"scripts": {
|
|
95
|
-
"
|
|
95
|
+
"build": "node install/build.js",
|
|
96
|
+
"install": "node install/check.js || npm run build",
|
|
96
97
|
"clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
|
|
97
|
-
"test": "npm run
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
98
|
+
"test": "npm run lint && npm run test-unit",
|
|
99
|
+
"lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
|
|
100
|
+
"lint-cpp": "cpplint --quiet src/*.h src/*.cc",
|
|
101
|
+
"lint-js": "biome lint",
|
|
102
|
+
"lint-types": "tsd --files ./test/types/sharp.test-d.ts",
|
|
101
103
|
"test-leak": "./test/leak/leak.sh",
|
|
102
|
-
"test-
|
|
104
|
+
"test-unit": "node --experimental-test-coverage test/unit.mjs",
|
|
103
105
|
"package-from-local-build": "node npm/from-local-build.js",
|
|
104
106
|
"package-release-notes": "node npm/release-notes.js",
|
|
105
107
|
"docs-build": "node docs/build.mjs",
|
|
@@ -138,53 +140,52 @@
|
|
|
138
140
|
],
|
|
139
141
|
"dependencies": {
|
|
140
142
|
"@img/colour": "^1.0.0",
|
|
141
|
-
"detect-libc": "^2.1.
|
|
142
|
-
"semver": "^7.7.
|
|
143
|
+
"detect-libc": "^2.1.2",
|
|
144
|
+
"semver": "^7.7.3"
|
|
143
145
|
},
|
|
144
146
|
"optionalDependencies": {
|
|
145
|
-
"@img/sharp-darwin-arm64": "0.34.
|
|
146
|
-
"@img/sharp-darwin-x64": "0.34.
|
|
147
|
-
"@img/sharp-libvips-darwin-arm64": "1.2.
|
|
148
|
-
"@img/sharp-libvips-darwin-x64": "1.2.
|
|
149
|
-
"@img/sharp-libvips-linux-arm": "1.2.
|
|
150
|
-
"@img/sharp-libvips-linux-arm64": "1.2.
|
|
151
|
-
"@img/sharp-libvips-linux-ppc64": "1.2.
|
|
152
|
-
"@img/sharp-libvips-linux-
|
|
153
|
-
"@img/sharp-libvips-linux-
|
|
154
|
-
"@img/sharp-libvips-
|
|
155
|
-
"@img/sharp-libvips-linuxmusl-
|
|
156
|
-
"@img/sharp-
|
|
157
|
-
"@img/sharp-linux-
|
|
158
|
-
"@img/sharp-linux-
|
|
159
|
-
"@img/sharp-linux-
|
|
160
|
-
"@img/sharp-linux-
|
|
161
|
-
"@img/sharp-
|
|
162
|
-
"@img/sharp-
|
|
163
|
-
"@img/sharp-
|
|
164
|
-
"@img/sharp-
|
|
165
|
-
"@img/sharp-
|
|
166
|
-
"@img/sharp-win32-
|
|
147
|
+
"@img/sharp-darwin-arm64": "0.34.5-rc.1",
|
|
148
|
+
"@img/sharp-darwin-x64": "0.34.5-rc.1",
|
|
149
|
+
"@img/sharp-libvips-darwin-arm64": "1.2.4",
|
|
150
|
+
"@img/sharp-libvips-darwin-x64": "1.2.4",
|
|
151
|
+
"@img/sharp-libvips-linux-arm": "1.2.4",
|
|
152
|
+
"@img/sharp-libvips-linux-arm64": "1.2.4",
|
|
153
|
+
"@img/sharp-libvips-linux-ppc64": "1.2.4",
|
|
154
|
+
"@img/sharp-libvips-linux-riscv64": "1.2.4",
|
|
155
|
+
"@img/sharp-libvips-linux-s390x": "1.2.4",
|
|
156
|
+
"@img/sharp-libvips-linux-x64": "1.2.4",
|
|
157
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.2.4",
|
|
158
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.2.4",
|
|
159
|
+
"@img/sharp-linux-arm": "0.34.5-rc.1",
|
|
160
|
+
"@img/sharp-linux-arm64": "0.34.5-rc.1",
|
|
161
|
+
"@img/sharp-linux-ppc64": "0.34.5-rc.1",
|
|
162
|
+
"@img/sharp-linux-riscv64": "0.34.5-rc.1",
|
|
163
|
+
"@img/sharp-linux-s390x": "0.34.5-rc.1",
|
|
164
|
+
"@img/sharp-linux-x64": "0.34.5-rc.1",
|
|
165
|
+
"@img/sharp-linuxmusl-arm64": "0.34.5-rc.1",
|
|
166
|
+
"@img/sharp-linuxmusl-x64": "0.34.5-rc.1",
|
|
167
|
+
"@img/sharp-wasm32": "0.34.5-rc.1",
|
|
168
|
+
"@img/sharp-win32-arm64": "0.34.5-rc.1",
|
|
169
|
+
"@img/sharp-win32-ia32": "0.34.5-rc.1",
|
|
170
|
+
"@img/sharp-win32-x64": "0.34.5-rc.1"
|
|
167
171
|
},
|
|
168
172
|
"devDependencies": {
|
|
169
|
-
"@
|
|
170
|
-
"@
|
|
171
|
-
"@
|
|
172
|
-
"@img/sharp-libvips-
|
|
173
|
-
"@img/sharp-libvips-
|
|
174
|
-
"@img/sharp-libvips-win32-
|
|
173
|
+
"@biomejs/biome": "^2.3.4",
|
|
174
|
+
"@cpplint/cli": "^0.1.0",
|
|
175
|
+
"@emnapi/runtime": "^1.7.0",
|
|
176
|
+
"@img/sharp-libvips-dev": "1.2.4",
|
|
177
|
+
"@img/sharp-libvips-dev-wasm32": "1.2.4",
|
|
178
|
+
"@img/sharp-libvips-win32-arm64": "1.2.4",
|
|
179
|
+
"@img/sharp-libvips-win32-ia32": "1.2.4",
|
|
180
|
+
"@img/sharp-libvips-win32-x64": "1.2.4",
|
|
175
181
|
"@types/node": "*",
|
|
176
|
-
"
|
|
177
|
-
"emnapi": "^1.5.0",
|
|
182
|
+
"emnapi": "^1.7.0",
|
|
178
183
|
"exif-reader": "^2.0.2",
|
|
179
184
|
"extract-zip": "^2.0.1",
|
|
180
185
|
"icc": "^3.0.0",
|
|
181
|
-
"jsdoc-to-markdown": "^9.1.
|
|
182
|
-
"license-checker": "^25.0.1",
|
|
183
|
-
"mocha": "^11.7.2",
|
|
186
|
+
"jsdoc-to-markdown": "^9.1.3",
|
|
184
187
|
"node-addon-api": "^8.5.0",
|
|
185
|
-
"node-gyp": "^11.
|
|
186
|
-
"nyc": "^17.1.0",
|
|
187
|
-
"semistandard": "^17.0.0",
|
|
188
|
+
"node-gyp": "^11.5.0",
|
|
188
189
|
"tar-fs": "^3.1.1",
|
|
189
190
|
"tsd": "^0.33.0"
|
|
190
191
|
},
|
|
@@ -193,28 +194,15 @@
|
|
|
193
194
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
194
195
|
},
|
|
195
196
|
"config": {
|
|
196
|
-
"libvips": ">=8.17.
|
|
197
|
+
"libvips": ">=8.17.3"
|
|
197
198
|
},
|
|
198
199
|
"funding": {
|
|
199
200
|
"url": "https://opencollective.com/libvips"
|
|
200
201
|
},
|
|
201
|
-
"semistandard": {
|
|
202
|
-
"env": [
|
|
203
|
-
"mocha"
|
|
204
|
-
]
|
|
205
|
-
},
|
|
206
202
|
"cc": {
|
|
207
203
|
"linelength": "120",
|
|
208
204
|
"filter": [
|
|
209
205
|
"build/include"
|
|
210
206
|
]
|
|
211
|
-
},
|
|
212
|
-
"nyc": {
|
|
213
|
-
"include": [
|
|
214
|
-
"lib"
|
|
215
|
-
]
|
|
216
|
-
},
|
|
217
|
-
"tsd": {
|
|
218
|
-
"directory": "test/types/"
|
|
219
207
|
}
|
|
220
208
|
}
|
package/src/common.cc
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
3
5
|
|
|
6
|
+
#include <algorithm>
|
|
4
7
|
#include <cstdlib>
|
|
8
|
+
#include <map>
|
|
9
|
+
#include <mutex>
|
|
10
|
+
#include <queue>
|
|
5
11
|
#include <string>
|
|
6
|
-
#include <
|
|
12
|
+
#include <tuple>
|
|
13
|
+
#include <utility>
|
|
7
14
|
#include <vector>
|
|
8
|
-
#include <queue>
|
|
9
|
-
#include <map>
|
|
10
|
-
#include <mutex> // NOLINT(build/c++11)
|
|
11
15
|
|
|
12
16
|
#include <napi.h>
|
|
13
17
|
#include <vips/vips8>
|
|
14
18
|
|
|
15
|
-
#include "common.h"
|
|
19
|
+
#include "./common.h"
|
|
16
20
|
|
|
17
21
|
using vips::VImage;
|
|
18
22
|
|