sharp 0.31.2 → 0.32.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/README.md +1 -1
- package/binding.gyp +1 -1
- package/install/can-compile.js +3 -0
- package/install/dll-copy.js +3 -0
- package/install/libvips.js +6 -6
- package/lib/agent.js +5 -1
- package/lib/channel.js +4 -1
- package/lib/colour.js +3 -0
- package/lib/composite.js +3 -0
- package/lib/constructor.js +23 -9
- package/lib/index.d.ts +1614 -0
- package/lib/index.js +3 -0
- package/lib/input.js +39 -8
- package/lib/is.js +12 -0
- package/lib/libvips.js +4 -0
- package/lib/operation.js +94 -52
- package/lib/output.js +113 -11
- package/lib/platform.js +3 -0
- package/lib/resize.js +54 -19
- package/lib/sharp.js +3 -0
- package/lib/utility.js +5 -1
- package/package.json +30 -23
- package/src/common.cc +43 -14
- package/src/common.h +22 -16
- package/src/libvips/cplusplus/vips-operators.cpp +7 -0
- package/src/metadata.cc +17 -22
- package/src/metadata.h +3 -13
- package/src/operations.cc +13 -23
- package/src/operations.h +4 -15
- package/src/pipeline.cc +129 -69
- package/src/pipeline.h +30 -15
- package/src/sharp.cc +2 -13
- package/src/stats.cc +7 -17
- package/src/stats.h +2 -13
- package/src/utilities.cc +17 -28
- package/src/utilities.h +2 -13
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ covers reporting bugs, requesting features and submitting code changes.
|
|
|
102
102
|
|
|
103
103
|
## Licensing
|
|
104
104
|
|
|
105
|
-
Copyright 2013
|
|
105
|
+
Copyright 2013 Lovell Fuller and others.
|
|
106
106
|
|
|
107
107
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
108
108
|
you may not use this file except in compliance with the License.
|
package/binding.gyp
CHANGED
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
],
|
|
180
180
|
'xcode_settings': {
|
|
181
181
|
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
|
|
182
|
-
'MACOSX_DEPLOYMENT_TARGET': '10.
|
|
182
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.13',
|
|
183
183
|
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
|
184
184
|
'GCC_ENABLE_CPP_RTTI': 'YES',
|
|
185
185
|
'OTHER_CPLUSPLUSFLAGS': [
|
package/install/can-compile.js
CHANGED
package/install/dll-copy.js
CHANGED
package/install/libvips.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
1
4
|
'use strict';
|
|
2
5
|
|
|
3
6
|
const fs = require('fs');
|
|
@@ -128,9 +131,6 @@ try {
|
|
|
128
131
|
if (arch === 'ia32' && !platformAndArch.startsWith('win32')) {
|
|
129
132
|
throw new Error(`Intel Architecture 32-bit systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
130
133
|
}
|
|
131
|
-
if (platformAndArch === 'darwin-arm64') {
|
|
132
|
-
throw new Error("Please run 'brew install vips' to install libvips on Apple M1 (ARM64) systems");
|
|
133
|
-
}
|
|
134
134
|
if (platformAndArch === 'freebsd-x64' || platformAndArch === 'openbsd-x64' || platformAndArch === 'sunos-x64') {
|
|
135
135
|
throw new Error(`BSD/SunOS systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
|
|
136
136
|
}
|
|
@@ -138,7 +138,8 @@ try {
|
|
|
138
138
|
const libcFamily = detectLibc.familySync();
|
|
139
139
|
const libcVersion = detectLibc.versionSync();
|
|
140
140
|
if (libcFamily === detectLibc.GLIBC && libcVersion && minimumGlibcVersionByArch[arch]) {
|
|
141
|
-
|
|
141
|
+
const libcVersionWithoutPatch = libcVersion.split('.').slice(0, 2).join('.');
|
|
142
|
+
if (semverLessThan(`${libcVersionWithoutPatch}.0`, `${minimumGlibcVersionByArch[arch]}.0`)) {
|
|
142
143
|
handleError(new Error(`Use with glibc ${libcVersion} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
|
|
143
144
|
}
|
|
144
145
|
}
|
|
@@ -152,7 +153,6 @@ try {
|
|
|
152
153
|
if (!semverSatisfies(process.versions.node, supportedNodeVersion)) {
|
|
153
154
|
handleError(new Error(`Expected Node.js version ${supportedNodeVersion} but found ${process.versions.node}`));
|
|
154
155
|
}
|
|
155
|
-
|
|
156
156
|
// Download to per-process temporary file
|
|
157
157
|
const tarFilename = ['libvips', minimumLibvipsVersionLabelled, platformAndArch].join('-') + '.tar.br';
|
|
158
158
|
const tarPathCache = path.join(libvips.cachePath(), tarFilename);
|
|
@@ -167,7 +167,7 @@ try {
|
|
|
167
167
|
} else {
|
|
168
168
|
const url = distBaseUrl + tarFilename;
|
|
169
169
|
libvips.log(`Downloading ${url}`);
|
|
170
|
-
simpleGet({ url: url, agent: agent() }, function (err, response) {
|
|
170
|
+
simpleGet({ url: url, agent: agent(libvips.log) }, function (err, response) {
|
|
171
171
|
if (err) {
|
|
172
172
|
fail(err);
|
|
173
173
|
} else if (response.statusCode === 404) {
|
package/lib/agent.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
1
4
|
'use strict';
|
|
2
5
|
|
|
3
6
|
const url = require('url');
|
|
@@ -18,7 +21,7 @@ function env (key) {
|
|
|
18
21
|
return process.env[key];
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
module.exports = function () {
|
|
24
|
+
module.exports = function (log) {
|
|
22
25
|
try {
|
|
23
26
|
const proxy = new url.URL(proxies.map(env).find(is.string));
|
|
24
27
|
const tunnel = proxy.protocol === 'https:'
|
|
@@ -27,6 +30,7 @@ module.exports = function () {
|
|
|
27
30
|
const proxyAuth = proxy.username && proxy.password
|
|
28
31
|
? `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`
|
|
29
32
|
: null;
|
|
33
|
+
log(`Via proxy ${proxy.protocol}://${proxy.hostname}:${proxy.port} ${proxyAuth ? 'with' : 'no'} credentials`);
|
|
30
34
|
return tunnel({
|
|
31
35
|
proxy: {
|
|
32
36
|
port: Number(proxy.port),
|
package/lib/channel.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
1
4
|
'use strict';
|
|
2
5
|
|
|
3
6
|
const is = require('./is');
|
|
@@ -98,7 +101,7 @@ function extractChannel (channel) {
|
|
|
98
101
|
} else {
|
|
99
102
|
throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);
|
|
100
103
|
}
|
|
101
|
-
return this
|
|
104
|
+
return this;
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/**
|
package/lib/colour.js
CHANGED
package/lib/composite.js
CHANGED
package/lib/constructor.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright 2013 Lovell Fuller and others.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
1
4
|
'use strict';
|
|
2
5
|
|
|
3
6
|
const util = require('util');
|
|
@@ -113,25 +116,25 @@ const debuglog = util.debuglog('sharp');
|
|
|
113
116
|
* }
|
|
114
117
|
* }).toFile('text_rgba.png');
|
|
115
118
|
*
|
|
116
|
-
* @param {(Buffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string)} [input] - if present, can be
|
|
117
|
-
* a Buffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or
|
|
119
|
+
* @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string)} [input] - if present, can be
|
|
120
|
+
* a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or
|
|
118
121
|
* a TypedArray containing raw pixel image data, or
|
|
119
122
|
* a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.
|
|
120
123
|
* JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
|
|
121
124
|
* @param {Object} [options] - if present, is an Object with optional attributes.
|
|
122
|
-
* @param {string} [options.failOn='warning'] -
|
|
125
|
+
* @param {string} [options.failOn='warning'] - when to abort processing of invalid pixel data, one of (in order of sensitivity): 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort.
|
|
123
126
|
* @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels
|
|
124
127
|
* (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.
|
|
125
128
|
* An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
|
|
126
129
|
* @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).
|
|
127
|
-
* @param {boolean} [options.sequentialRead=
|
|
128
|
-
* This can reduce memory usage and might improve performance on some systems.
|
|
130
|
+
* @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
|
|
129
131
|
* @param {number} [options.density=72] - number representing the DPI for vector images in the range 1 to 100000.
|
|
130
|
-
* @param {number} [options.
|
|
131
|
-
* @param {number} [options.
|
|
132
|
+
* @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
|
|
133
|
+
* @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.
|
|
134
|
+
* @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
|
|
132
135
|
* @param {number} [options.subifd=-1] - subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image.
|
|
133
136
|
* @param {number} [options.level=0] - level to extract from a multi-level input (OpenSlide), zero based.
|
|
134
|
-
* @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1
|
|
137
|
+
* @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.
|
|
135
138
|
* @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
|
|
136
139
|
* @param {number} [options.raw.width] - integral number of pixels wide.
|
|
137
140
|
* @param {number} [options.raw.height] - integral number of pixels high.
|
|
@@ -158,6 +161,7 @@ const debuglog = util.debuglog('sharp');
|
|
|
158
161
|
* @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
|
|
159
162
|
* @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground="red">Red!</span>`.
|
|
160
163
|
* @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
|
|
164
|
+
* @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'charWord' (prefer char, fallback to word) or 'none'.
|
|
161
165
|
* @returns {Sharp}
|
|
162
166
|
* @throws {Error} Invalid parameters
|
|
163
167
|
*/
|
|
@@ -196,6 +200,7 @@ const Sharp = function (input, options) {
|
|
|
196
200
|
extendLeft: 0,
|
|
197
201
|
extendRight: 0,
|
|
198
202
|
extendBackground: [0, 0, 0, 255],
|
|
203
|
+
extendWith: 'background',
|
|
199
204
|
withoutEnlargement: false,
|
|
200
205
|
withoutReduction: false,
|
|
201
206
|
affineMatrix: [],
|
|
@@ -230,6 +235,8 @@ const Sharp = function (input, options) {
|
|
|
230
235
|
gammaOut: 0,
|
|
231
236
|
greyscale: false,
|
|
232
237
|
normalise: false,
|
|
238
|
+
normaliseLower: 1,
|
|
239
|
+
normaliseUpper: 99,
|
|
233
240
|
claheWidth: 0,
|
|
234
241
|
claheHeight: 0,
|
|
235
242
|
claheMaxSlope: 3,
|
|
@@ -289,7 +296,10 @@ const Sharp = function (input, options) {
|
|
|
289
296
|
gifBitdepth: 8,
|
|
290
297
|
gifEffort: 7,
|
|
291
298
|
gifDither: 1,
|
|
292
|
-
|
|
299
|
+
gifInterFrameMaxError: 0,
|
|
300
|
+
gifInterPaletteMaxError: 3,
|
|
301
|
+
gifReuse: true,
|
|
302
|
+
gifProgressive: false,
|
|
293
303
|
tiffQuality: 80,
|
|
294
304
|
tiffCompression: 'jpeg',
|
|
295
305
|
tiffPredictor: 'horizontal',
|
|
@@ -306,6 +316,10 @@ const Sharp = function (input, options) {
|
|
|
306
316
|
heifCompression: 'av1',
|
|
307
317
|
heifEffort: 4,
|
|
308
318
|
heifChromaSubsampling: '4:4:4',
|
|
319
|
+
jxlDistance: 1,
|
|
320
|
+
jxlDecodingTier: 0,
|
|
321
|
+
jxlEffort: 7,
|
|
322
|
+
jxlLossless: false,
|
|
309
323
|
rawDepth: 'uchar',
|
|
310
324
|
tileSize: 256,
|
|
311
325
|
tileOverlap: 0,
|