sharp 0.30.4 → 0.30.5
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 +9 -1
- package/lib/composite.js +1 -1
- package/lib/input.js +2 -2
- package/lib/libvips.js +10 -2
- package/lib/output.js +4 -1
- package/lib/platform.js +5 -3
- package/lib/sharp.js +1 -1
- package/lib/utility.js +17 -4
- package/package.json +6 -5
- package/src/pipeline.cc +10 -8
package/install/libvips.js
CHANGED
|
@@ -35,6 +35,7 @@ const hasSharpPrebuild = [
|
|
|
35
35
|
];
|
|
36
36
|
|
|
37
37
|
const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
|
|
38
|
+
const localLibvipsDir = process.env.npm_config_sharp_libvips_local_prebuilds || '';
|
|
38
39
|
const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
|
|
39
40
|
const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
|
|
40
41
|
const installationForced = !!(process.env.npm_config_sharp_install_force || process.env.SHARP_INSTALL_FORCE);
|
|
@@ -42,7 +43,9 @@ const installationForced = !!(process.env.npm_config_sharp_install_force || proc
|
|
|
42
43
|
const fail = function (err) {
|
|
43
44
|
libvips.log(err);
|
|
44
45
|
if (err.code === 'EACCES') {
|
|
45
|
-
libvips.log('Are you trying to install as a root or sudo user?
|
|
46
|
+
libvips.log('Are you trying to install as a root or sudo user?');
|
|
47
|
+
libvips.log('- For npm <= v6, try again with the "--unsafe-perm" flag');
|
|
48
|
+
libvips.log('- For npm >= v8, the user must own the directory "npm install" is run in');
|
|
46
49
|
}
|
|
47
50
|
libvips.log('Please see https://sharp.pixelplumbing.com/install for required dependencies');
|
|
48
51
|
process.exit(1);
|
|
@@ -156,6 +159,11 @@ try {
|
|
|
156
159
|
if (fs.existsSync(tarPathCache)) {
|
|
157
160
|
libvips.log(`Using cached ${tarPathCache}`);
|
|
158
161
|
extractTarball(tarPathCache, platformAndArch);
|
|
162
|
+
} else if (localLibvipsDir) {
|
|
163
|
+
// If localLibvipsDir is given try to use binaries from local directory
|
|
164
|
+
const tarPathLocal = path.join(path.resolve(localLibvipsDir), `v${minimumLibvipsVersionLabelled}`, tarFilename);
|
|
165
|
+
libvips.log(`Using local libvips from ${tarPathLocal}`);
|
|
166
|
+
extractTarball(tarPathLocal, platformAndArch);
|
|
159
167
|
} else {
|
|
160
168
|
const url = distBaseUrl + tarFilename;
|
|
161
169
|
libvips.log(`Downloading ${url}`);
|
package/lib/composite.js
CHANGED
|
@@ -50,7 +50,7 @@ const blend = {
|
|
|
50
50
|
* `hard-light`, `soft-light`, `difference`, `exclusion`.
|
|
51
51
|
*
|
|
52
52
|
* More information about blend modes can be found at
|
|
53
|
-
* https://libvips.
|
|
53
|
+
* https://www.libvips.org/API/current/libvips-conversion.html#VipsBlendMode
|
|
54
54
|
* and https://www.cairographics.org/operators/
|
|
55
55
|
*
|
|
56
56
|
* @since 0.22.0
|
package/lib/input.js
CHANGED
|
@@ -309,9 +309,9 @@ function _isStreamInput () {
|
|
|
309
309
|
* - `size`: Total size of image in bytes, for Stream and Buffer input only
|
|
310
310
|
* - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)
|
|
311
311
|
* - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)
|
|
312
|
-
* - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://libvips.
|
|
312
|
+
* - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/VipsImage.html#VipsInterpretation)
|
|
313
313
|
* - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
|
314
|
-
* - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://libvips.
|
|
314
|
+
* - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/VipsImage.html#VipsBandFormat)
|
|
315
315
|
* - `density`: Number of pixels per inch (DPI), if present
|
|
316
316
|
* - `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
|
|
317
317
|
* - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan
|
package/lib/libvips.js
CHANGED
|
@@ -65,7 +65,12 @@ const isRosetta = function () {
|
|
|
65
65
|
|
|
66
66
|
const globalLibvipsVersion = function () {
|
|
67
67
|
if (process.platform !== 'win32') {
|
|
68
|
-
const globalLibvipsVersion = spawnSync(
|
|
68
|
+
const globalLibvipsVersion = spawnSync('pkg-config --modversion vips-cpp', {
|
|
69
|
+
...spawnSyncOptions,
|
|
70
|
+
env: {
|
|
71
|
+
PKG_CONFIG_PATH: pkgConfigPath()
|
|
72
|
+
}
|
|
73
|
+
}).stdout;
|
|
69
74
|
/* istanbul ignore next */
|
|
70
75
|
return (globalLibvipsVersion || '').trim();
|
|
71
76
|
} else {
|
|
@@ -85,7 +90,10 @@ const removeVendoredLibvips = function () {
|
|
|
85
90
|
|
|
86
91
|
const pkgConfigPath = function () {
|
|
87
92
|
if (process.platform !== 'win32') {
|
|
88
|
-
const brewPkgConfigPath = spawnSync(
|
|
93
|
+
const brewPkgConfigPath = spawnSync(
|
|
94
|
+
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
|
|
95
|
+
spawnSyncOptions
|
|
96
|
+
).stdout || '';
|
|
89
97
|
return [
|
|
90
98
|
brewPkgConfigPath.trim(),
|
|
91
99
|
env.PKG_CONFIG_PATH,
|
package/lib/output.js
CHANGED
|
@@ -82,6 +82,8 @@ function toFile (fileOut, callback) {
|
|
|
82
82
|
* Write output to a Buffer.
|
|
83
83
|
* JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.
|
|
84
84
|
*
|
|
85
|
+
* Use {@link toFormat} or one of the format-specific functions such as {@link jpeg}, {@link png} etc. to set the output format.
|
|
86
|
+
*
|
|
85
87
|
* If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.
|
|
86
88
|
*
|
|
87
89
|
* By default all metadata will be removed, which includes EXIF-based orientation.
|
|
@@ -108,6 +110,7 @@ function toFile (fileOut, callback) {
|
|
|
108
110
|
*
|
|
109
111
|
* @example
|
|
110
112
|
* sharp(input)
|
|
113
|
+
* .png()
|
|
111
114
|
* .toBuffer({ resolveWithObject: true })
|
|
112
115
|
* .then(({ data, info }) => { ... })
|
|
113
116
|
* .catch(err => { ... });
|
|
@@ -516,7 +519,7 @@ function webp (options) {
|
|
|
516
519
|
* // Convert PNG to GIF
|
|
517
520
|
* await sharp(pngBuffer)
|
|
518
521
|
* .gif()
|
|
519
|
-
* .toBuffer()
|
|
522
|
+
* .toBuffer();
|
|
520
523
|
*
|
|
521
524
|
* @example
|
|
522
525
|
* // Convert animated WebP to animated GIF
|
package/lib/platform.js
CHANGED
|
@@ -7,10 +7,12 @@ const env = process.env;
|
|
|
7
7
|
module.exports = function () {
|
|
8
8
|
const arch = env.npm_config_arch || process.arch;
|
|
9
9
|
const platform = env.npm_config_platform || process.platform;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const libc = process.env.npm_config_libc ||
|
|
11
|
+
/* istanbul ignore next */
|
|
12
|
+
(detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : '');
|
|
13
|
+
const libcId = platform !== 'linux' || libc === detectLibc.GLIBC ? '' : libc;
|
|
12
14
|
|
|
13
|
-
const platformId = [`${platform}${
|
|
15
|
+
const platformId = [`${platform}${libcId}`];
|
|
14
16
|
|
|
15
17
|
if (arch === 'arm') {
|
|
16
18
|
const fallback = process.versions.electron ? '7' : '6';
|
package/lib/sharp.js
CHANGED
|
@@ -13,7 +13,7 @@ try {
|
|
|
13
13
|
} else {
|
|
14
14
|
const [platform, arch] = platformAndArch.split('-');
|
|
15
15
|
help.push(
|
|
16
|
-
'- Install with
|
|
16
|
+
'- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"',
|
|
17
17
|
`- Install for the current ${platformAndArch} runtime: "npm install --platform=${platform} --arch=${arch} sharp"`
|
|
18
18
|
);
|
|
19
19
|
}
|
package/lib/utility.js
CHANGED
|
@@ -103,7 +103,11 @@ cache(true);
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Gets or, when a concurrency is provided, sets
|
|
106
|
-
* the number of threads
|
|
106
|
+
* the maximum number of threads _libvips_ should use to process _each image_.
|
|
107
|
+
* These are from a thread pool managed by glib,
|
|
108
|
+
* which helps avoid the overhead of creating new threads.
|
|
109
|
+
*
|
|
110
|
+
* This method always returns the current concurrency.
|
|
107
111
|
*
|
|
108
112
|
* The default value is the number of CPU cores,
|
|
109
113
|
* except when using glibc-based Linux without jemalloc,
|
|
@@ -111,10 +115,19 @@ cache(true);
|
|
|
111
115
|
*
|
|
112
116
|
* A value of `0` will reset this to the number of CPU cores.
|
|
113
117
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
118
|
+
* Some image format libraries spawn additional threads,
|
|
119
|
+
* e.g. libaom manages its own 4 threads when encoding AVIF images,
|
|
120
|
+
* and these are independent of the value set here.
|
|
116
121
|
*
|
|
117
|
-
*
|
|
122
|
+
* The maximum number of images that sharp can process in parallel
|
|
123
|
+
* is controlled by libuv's `UV_THREADPOOL_SIZE` environment variable,
|
|
124
|
+
* which defaults to 4.
|
|
125
|
+
*
|
|
126
|
+
* https://nodejs.org/api/cli.html#uv_threadpool_sizesize
|
|
127
|
+
*
|
|
128
|
+
* For example, by default, a machine with 8 CPU cores will process
|
|
129
|
+
* 4 images in parallel and use up to 8 threads per image,
|
|
130
|
+
* so there will be up to 32 concurrent threads.
|
|
118
131
|
*
|
|
119
132
|
* @example
|
|
120
133
|
* const threads = sharp.concurrency(); // 4
|
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.30.
|
|
4
|
+
"version": "0.30.5",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -82,7 +82,8 @@
|
|
|
82
82
|
"Joris Dugué <zaruike10@gmail.com>",
|
|
83
83
|
"Chris Banks <christopher.bradley.banks@gmail.com>",
|
|
84
84
|
"Ompal Singh <ompal.hitm09@gmail.com>",
|
|
85
|
-
"Brodan <christopher.hranj@gmail.com"
|
|
85
|
+
"Brodan <christopher.hranj@gmail.com",
|
|
86
|
+
"Ankur Parihar <ankur.github@gmail.com>"
|
|
86
87
|
],
|
|
87
88
|
"scripts": {
|
|
88
89
|
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)",
|
|
@@ -129,8 +130,8 @@
|
|
|
129
130
|
"dependencies": {
|
|
130
131
|
"color": "^4.2.3",
|
|
131
132
|
"detect-libc": "^2.0.1",
|
|
132
|
-
"node-addon-api": "^
|
|
133
|
-
"prebuild-install": "^7.0
|
|
133
|
+
"node-addon-api": "^5.0.0",
|
|
134
|
+
"prebuild-install": "^7.1.0",
|
|
134
135
|
"semver": "^7.3.7",
|
|
135
136
|
"simple-get": "^4.0.1",
|
|
136
137
|
"tar-fs": "^2.1.1",
|
|
@@ -144,7 +145,7 @@
|
|
|
144
145
|
"exif-reader": "^1.0.3",
|
|
145
146
|
"icc": "^2.0.0",
|
|
146
147
|
"license-checker": "^25.0.1",
|
|
147
|
-
"mocha": "^
|
|
148
|
+
"mocha": "^10.0.0",
|
|
148
149
|
"mock-fs": "^5.1.2",
|
|
149
150
|
"nyc": "^15.1.0",
|
|
150
151
|
"prebuild": "^11.0.3",
|
package/src/pipeline.cc
CHANGED
|
@@ -95,16 +95,18 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
95
95
|
if (baton->rotateBeforePreExtract) {
|
|
96
96
|
if (rotation != VIPS_ANGLE_D0) {
|
|
97
97
|
image = image.rot(rotation);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
}
|
|
99
|
+
if (flip) {
|
|
100
|
+
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
|
101
|
+
}
|
|
102
|
+
if (flop) {
|
|
103
|
+
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
|
104
|
+
}
|
|
105
|
+
if (rotation != VIPS_ANGLE_D0 || flip || flop) {
|
|
106
106
|
image = sharp::RemoveExifOrientation(image);
|
|
107
107
|
}
|
|
108
|
+
flop = FALSE;
|
|
109
|
+
flip = FALSE;
|
|
108
110
|
if (baton->rotationAngle != 0.0) {
|
|
109
111
|
MultiPageUnsupported(nPages, "Rotate");
|
|
110
112
|
std::vector<double> background;
|