sharp 0.33.0 → 0.33.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install/check.js +33 -28
- package/lib/index.d.ts +1 -1
- package/lib/libvips.js +14 -1
- package/lib/sharp.js +42 -20
- package/lib/utility.js +3 -4
- package/package.json +12 -12
- package/src/binding.gyp +5 -2
- package/src/pipeline.cc +9 -5
package/install/check.js
CHANGED
|
@@ -3,34 +3,39 @@
|
|
|
3
3
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
try {
|
|
7
|
+
const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
|
|
7
8
|
|
|
8
|
-
const buildFromSource = (msg) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
9
|
+
const buildFromSource = (msg) => {
|
|
10
|
+
log(msg);
|
|
11
|
+
log('Attempting to build from source via node-gyp');
|
|
12
|
+
try {
|
|
13
|
+
require('node-addon-api');
|
|
14
|
+
log('Found node-addon-api');
|
|
15
|
+
} catch (err) {
|
|
16
|
+
log('Please add node-addon-api to your dependencies');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const gyp = require('node-gyp');
|
|
21
|
+
log(`Found node-gyp version ${gyp().version}`);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
log('Please add node-gyp to your dependencies');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
log('See https://sharp.pixelplumbing.com/install#building-from-source');
|
|
27
|
+
const status = spawnRebuild();
|
|
28
|
+
if (status !== 0) {
|
|
29
|
+
process.exit(status);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
31
32
|
|
|
32
|
-
if (useGlobalLibvips()) {
|
|
33
|
-
|
|
34
|
-
} else if (process.env.npm_config_build_from_source) {
|
|
35
|
-
|
|
33
|
+
if (useGlobalLibvips()) {
|
|
34
|
+
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
|
35
|
+
} else if (process.env.npm_config_build_from_source) {
|
|
36
|
+
buildFromSource('Detected --build-from-source flag');
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
const summary = err.message.split(/\n/).slice(0, 1);
|
|
40
|
+
console.log(`sharp: skipping install check: ${summary}`);
|
|
36
41
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ declare namespace sharp {
|
|
|
126
126
|
function counters(): SharpCounters;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with
|
|
129
|
+
* Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with highway support.
|
|
130
130
|
* Improves the performance of resize, blur and sharpen operations by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
|
|
131
131
|
* @param enable enable or disable use of SIMD vector unit instructions
|
|
132
132
|
* @returns true if usage of SIMD vector unit instructions is enabled
|
package/lib/libvips.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
const { spawnSync } = require('node:child_process');
|
|
7
|
+
const { createHash } = require('node:crypto');
|
|
7
8
|
const semverCoerce = require('semver/functions/coerce');
|
|
8
9
|
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
|
|
9
10
|
const detectLibc = require('detect-libc');
|
|
10
11
|
|
|
11
|
-
const { engines } = require('../package.json');
|
|
12
|
+
const { engines, optionalDependencies } = require('../package.json');
|
|
12
13
|
|
|
13
14
|
const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || /* istanbul ignore next */
|
|
14
15
|
engines.libvips;
|
|
@@ -97,6 +98,17 @@ const isRosetta = () => {
|
|
|
97
98
|
return false;
|
|
98
99
|
};
|
|
99
100
|
|
|
101
|
+
const sha512 = (s) => createHash('sha512').update(s).digest('hex');
|
|
102
|
+
|
|
103
|
+
const yarnLocator = () => {
|
|
104
|
+
try {
|
|
105
|
+
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
|
106
|
+
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
|
107
|
+
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
|
108
|
+
} catch {}
|
|
109
|
+
return '';
|
|
110
|
+
};
|
|
111
|
+
|
|
100
112
|
/* istanbul ignore next */
|
|
101
113
|
const spawnRebuild = () =>
|
|
102
114
|
spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {
|
|
@@ -164,6 +176,7 @@ module.exports = {
|
|
|
164
176
|
buildSharpLibvipsLibDir,
|
|
165
177
|
runtimePlatformArch,
|
|
166
178
|
log,
|
|
179
|
+
yarnLocator,
|
|
167
180
|
spawnRebuild,
|
|
168
181
|
globalLibvipsVersion,
|
|
169
182
|
pkgConfigPath,
|
package/lib/sharp.js
CHANGED
|
@@ -46,41 +46,63 @@ if (sharp) {
|
|
|
46
46
|
// Common error messages
|
|
47
47
|
if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
48
48
|
const [os, cpu] = runtimePlatform.split('-');
|
|
49
|
-
help.push(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
help.push(
|
|
50
|
+
'- Ensure optional dependencies can be installed:',
|
|
51
|
+
' npm install --include=optional sharp',
|
|
52
|
+
' yarn add sharp --ignore-engines',
|
|
53
|
+
'- Ensure your package manager supports multi-platform installation:',
|
|
54
|
+
' See https://sharp.pixelplumbing.com/install#cross-platform',
|
|
55
|
+
'- Add platform-specific dependencies:',
|
|
56
|
+
` npm install --os=${os} --cpu=${cpu} sharp`,
|
|
57
|
+
` npm install --force @img/sharp-${runtimePlatform}`
|
|
58
|
+
);
|
|
53
59
|
} else {
|
|
54
|
-
help.push(
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
help.push(
|
|
61
|
+
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
|
62
|
+
'- Add experimental WebAssembly-based dependencies:',
|
|
63
|
+
' npm install --cpu=wasm32 sharp',
|
|
64
|
+
' npm install --force @img/sharp-wasm32'
|
|
65
|
+
);
|
|
57
66
|
}
|
|
58
|
-
if (isLinux && /symbol not found/i.test(messages)) {
|
|
67
|
+
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
|
59
68
|
try {
|
|
60
69
|
const { engines } = require(`@img/sharp-libvips-${runtimePlatform}/package`);
|
|
61
70
|
const libcFound = `${familySync()} ${versionSync()}`;
|
|
62
71
|
const libcRequires = `${engines.musl ? 'musl' : 'glibc'} ${engines.musl || engines.glibc}`;
|
|
63
|
-
help.push(
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
help.push(
|
|
73
|
+
'- Update your OS:',
|
|
74
|
+
` Found ${libcFound}`,
|
|
75
|
+
` Requires ${libcRequires}`
|
|
76
|
+
);
|
|
66
77
|
} catch (errEngines) {}
|
|
67
78
|
}
|
|
79
|
+
if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
|
|
80
|
+
help.push(
|
|
81
|
+
'- Remove the Node.js Snap, which does not support native modules',
|
|
82
|
+
' snap remove node'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
68
85
|
if (isMacOs && /Incompatible library version/.test(messages)) {
|
|
69
|
-
help.push(
|
|
70
|
-
|
|
86
|
+
help.push(
|
|
87
|
+
'- Update Homebrew:',
|
|
88
|
+
' brew update && brew upgrade vips'
|
|
89
|
+
);
|
|
71
90
|
}
|
|
72
91
|
if (errors.some(err => err.code === 'ERR_DLOPEN_DISABLED')) {
|
|
73
92
|
help.push('- Run Node.js without using the --no-addons flag');
|
|
74
93
|
}
|
|
75
|
-
if (process.versions.pnp) {
|
|
76
|
-
help.push('- Use a supported yarn linker, either pnpm or node-modules:');
|
|
77
|
-
help.push(' yarn config set nodeLinker node-modules');
|
|
78
|
-
}
|
|
79
94
|
// Link to installation docs
|
|
80
95
|
if (isWindows && /The specified procedure could not be found/.test(messages)) {
|
|
81
|
-
help.push(
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
help.push(
|
|
97
|
+
'- Using the canvas package on Windows?',
|
|
98
|
+
' See https://sharp.pixelplumbing.com/install#canvas-and-windows',
|
|
99
|
+
'- Check for outdated versions of sharp in the dependency tree:',
|
|
100
|
+
' npm ls sharp'
|
|
101
|
+
);
|
|
84
102
|
}
|
|
103
|
+
help.push(
|
|
104
|
+
'- Consult the installation documentation:',
|
|
105
|
+
' See https://sharp.pixelplumbing.com/install'
|
|
106
|
+
);
|
|
85
107
|
throw new Error(help.join('\n'));
|
|
86
108
|
}
|
package/lib/utility.js
CHANGED
|
@@ -183,17 +183,17 @@ function counters () {
|
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* Get and set use of SIMD vector unit instructions.
|
|
186
|
-
* Requires libvips to have been compiled with
|
|
186
|
+
* Requires libvips to have been compiled with highway support.
|
|
187
187
|
*
|
|
188
188
|
* Improves the performance of `resize`, `blur` and `sharpen` operations
|
|
189
189
|
* by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.
|
|
190
190
|
*
|
|
191
191
|
* @example
|
|
192
192
|
* const simd = sharp.simd();
|
|
193
|
-
* // simd is `true` if the runtime use of
|
|
193
|
+
* // simd is `true` if the runtime use of highway is currently enabled
|
|
194
194
|
* @example
|
|
195
195
|
* const simd = sharp.simd(false);
|
|
196
|
-
* // prevent libvips from using
|
|
196
|
+
* // prevent libvips from using highway at runtime
|
|
197
197
|
*
|
|
198
198
|
* @param {boolean} [simd=true]
|
|
199
199
|
* @returns {boolean}
|
|
@@ -201,7 +201,6 @@ function counters () {
|
|
|
201
201
|
function simd (simd) {
|
|
202
202
|
return sharp.simd(is.bool(simd) ? simd : null);
|
|
203
203
|
}
|
|
204
|
-
simd(true);
|
|
205
204
|
|
|
206
205
|
/**
|
|
207
206
|
* Block libvips operations at runtime.
|
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.33.
|
|
4
|
+
"version": "0.33.1-rc.2",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -141,8 +141,8 @@
|
|
|
141
141
|
"semver": "^7.5.4"
|
|
142
142
|
},
|
|
143
143
|
"optionalDependencies": {
|
|
144
|
-
"@img/sharp-darwin-arm64": "0.33.
|
|
145
|
-
"@img/sharp-darwin-x64": "0.33.
|
|
144
|
+
"@img/sharp-darwin-arm64": "0.33.1-rc.2",
|
|
145
|
+
"@img/sharp-darwin-x64": "0.33.1-rc.2",
|
|
146
146
|
"@img/sharp-libvips-darwin-arm64": "1.0.0",
|
|
147
147
|
"@img/sharp-libvips-darwin-x64": "1.0.0",
|
|
148
148
|
"@img/sharp-libvips-linux-arm": "1.0.0",
|
|
@@ -151,15 +151,15 @@
|
|
|
151
151
|
"@img/sharp-libvips-linux-x64": "1.0.0",
|
|
152
152
|
"@img/sharp-libvips-linuxmusl-arm64": "1.0.0",
|
|
153
153
|
"@img/sharp-libvips-linuxmusl-x64": "1.0.0",
|
|
154
|
-
"@img/sharp-linux-arm": "0.33.
|
|
155
|
-
"@img/sharp-linux-arm64": "0.33.
|
|
156
|
-
"@img/sharp-linux-s390x": "0.33.
|
|
157
|
-
"@img/sharp-linux-x64": "0.33.
|
|
158
|
-
"@img/sharp-linuxmusl-arm64": "0.33.
|
|
159
|
-
"@img/sharp-linuxmusl-x64": "0.33.
|
|
160
|
-
"@img/sharp-wasm32": "0.33.
|
|
161
|
-
"@img/sharp-win32-ia32": "0.33.
|
|
162
|
-
"@img/sharp-win32-x64": "0.33.
|
|
154
|
+
"@img/sharp-linux-arm": "0.33.1-rc.2",
|
|
155
|
+
"@img/sharp-linux-arm64": "0.33.1-rc.2",
|
|
156
|
+
"@img/sharp-linux-s390x": "0.33.1-rc.2",
|
|
157
|
+
"@img/sharp-linux-x64": "0.33.1-rc.2",
|
|
158
|
+
"@img/sharp-linuxmusl-arm64": "0.33.1-rc.2",
|
|
159
|
+
"@img/sharp-linuxmusl-x64": "0.33.1-rc.2",
|
|
160
|
+
"@img/sharp-wasm32": "0.33.1-rc.2",
|
|
161
|
+
"@img/sharp-win32-ia32": "0.33.1-rc.2",
|
|
162
|
+
"@img/sharp-win32-x64": "0.33.1-rc.2"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
165
|
"@emnapi/runtime": "^0.44.0",
|
package/src/binding.gyp
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
'vips_version': '<!(node -p "require(\'../lib/libvips\').minimumLibvipsVersion")',
|
|
7
7
|
'platform_and_arch': '<!(node -p "require(\'../lib/libvips\').buildPlatformArch()")',
|
|
8
8
|
'sharp_libvips_version': '<!(node -p "require(\'../package.json\').optionalDependencies[\'@img/sharp-libvips-<(platform_and_arch)\']")',
|
|
9
|
+
'sharp_libvips_yarn_locator': '<!(node -p "require(\'../lib/libvips\').yarnLocator()")',
|
|
9
10
|
'sharp_libvips_include_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsIncludeDir()")',
|
|
10
11
|
'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsCPlusPlusDir()")',
|
|
11
12
|
'sharp_libvips_lib_dir': '<!(node -p "require(\'../lib/libvips\').buildSharpLibvipsLibDir()")'
|
|
@@ -157,7 +158,8 @@
|
|
|
157
158
|
'-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
158
159
|
'-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
159
160
|
'-Wl,-rpath,\'@loader_path/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
160
|
-
'-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
161
|
+
'-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
162
|
+
'-Wl,-rpath,\'@loader_path/../../../../../@img-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
161
163
|
]
|
|
162
164
|
}
|
|
163
165
|
}],
|
|
@@ -176,7 +178,8 @@
|
|
|
176
178
|
'-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
177
179
|
'-Wl,-rpath=\'$$ORIGIN/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
178
180
|
'-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
179
|
-
'-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
181
|
+
'-Wl,-rpath=\'$$ORIGIN/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
182
|
+
'-Wl,-rpath,\'$$ORIGIN/../../../../../@img-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
180
183
|
]
|
|
181
184
|
}
|
|
182
185
|
}],
|
package/src/pipeline.cc
CHANGED
|
@@ -794,11 +794,15 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
794
794
|
|
|
795
795
|
// Apply output ICC profile
|
|
796
796
|
if (!baton->withIccProfile.empty()) {
|
|
797
|
-
|
|
798
|
-
->
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
797
|
+
try {
|
|
798
|
+
image = image.icc_transform(const_cast<char*>(baton->withIccProfile.data()), VImage::option()
|
|
799
|
+
->set("input_profile", processingProfile)
|
|
800
|
+
->set("embedded", TRUE)
|
|
801
|
+
->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
|
|
802
|
+
->set("intent", VIPS_INTENT_PERCEPTUAL));
|
|
803
|
+
} catch(...) {
|
|
804
|
+
sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid profile", nullptr);
|
|
805
|
+
}
|
|
802
806
|
} else if (baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) {
|
|
803
807
|
image = sharp::SetProfile(image, inputProfile);
|
|
804
808
|
}
|