sharp 0.31.3 → 0.32.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/README.md CHANGED
@@ -98,11 +98,9 @@ readableStream
98
98
  A [guide for contributors](https://github.com/lovell/sharp/blob/main/.github/CONTRIBUTING.md)
99
99
  covers reporting bugs, requesting features and submitting code changes.
100
100
 
101
- [![Node-API v5](https://img.shields.io/badge/Node--API-v5-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix)
102
-
103
101
  ## Licensing
104
102
 
105
- Copyright 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Lovell Fuller and contributors.
103
+ Copyright 2013 Lovell Fuller and others.
106
104
 
107
105
  Licensed under the Apache License, Version 2.0 (the "License");
108
106
  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.9',
182
+ 'MACOSX_DEPLOYMENT_TARGET': '10.13',
183
183
  'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
184
184
  'GCC_ENABLE_CPP_RTTI': 'YES',
185
185
  'OTHER_CPLUSPLUSFLAGS': [
@@ -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 libvips = require('../lib/libvips');
@@ -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');
@@ -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');
@@ -8,6 +11,7 @@ const zlib = require('zlib');
8
11
  const { createHash } = require('crypto');
9
12
 
10
13
  const detectLibc = require('detect-libc');
14
+ const semverCoerce = require('semver/functions/coerce');
11
15
  const semverLessThan = require('semver/functions/lt');
12
16
  const semverSatisfies = require('semver/functions/satisfies');
13
17
  const simpleGet = require('simple-get');
@@ -74,7 +78,11 @@ const verifyIntegrity = function (platformAndArch) {
74
78
  flush: function (done) {
75
79
  const digest = `sha512-${hash.digest('base64')}`;
76
80
  if (expected !== digest) {
77
- libvips.removeVendoredLibvips();
81
+ try {
82
+ libvips.removeVendoredLibvips();
83
+ } catch (err) {
84
+ libvips.log(err.message);
85
+ }
78
86
  libvips.log(`Integrity expected: ${expected}`);
79
87
  libvips.log(`Integrity received: ${digest}`);
80
88
  done(new Error(`Integrity check failed for ${platformAndArch}`));
@@ -128,24 +136,23 @@ try {
128
136
  if (arch === 'ia32' && !platformAndArch.startsWith('win32')) {
129
137
  throw new Error(`Intel Architecture 32-bit systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
130
138
  }
131
- if (platformAndArch === 'darwin-arm64') {
132
- throw new Error("Please run 'brew install vips' to install libvips on Apple M1 (ARM64) systems");
133
- }
134
139
  if (platformAndArch === 'freebsd-x64' || platformAndArch === 'openbsd-x64' || platformAndArch === 'sunos-x64') {
135
140
  throw new Error(`BSD/SunOS systems require manual installation of libvips >= ${minimumLibvipsVersion}`);
136
141
  }
137
142
  // Linux libc version check
138
- const libcFamily = detectLibc.familySync();
139
- const libcVersion = detectLibc.versionSync();
140
- if (libcFamily === detectLibc.GLIBC && libcVersion && minimumGlibcVersionByArch[arch]) {
141
- const libcVersionWithoutPatch = libcVersion.split('.').slice(0, 2).join('.');
142
- if (semverLessThan(`${libcVersionWithoutPatch}.0`, `${minimumGlibcVersionByArch[arch]}.0`)) {
143
- handleError(new Error(`Use with glibc ${libcVersion} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
143
+ const libcVersionRaw = detectLibc.versionSync();
144
+ if (libcVersionRaw) {
145
+ const libcFamily = detectLibc.familySync();
146
+ const libcVersion = semverCoerce(libcVersionRaw).version;
147
+ if (libcFamily === detectLibc.GLIBC && minimumGlibcVersionByArch[arch]) {
148
+ if (semverLessThan(libcVersion, semverCoerce(minimumGlibcVersionByArch[arch]).version)) {
149
+ handleError(new Error(`Use with glibc ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
150
+ }
144
151
  }
145
- }
146
- if (libcFamily === detectLibc.MUSL && libcVersion) {
147
- if (semverLessThan(libcVersion, '1.1.24')) {
148
- handleError(new Error(`Use with musl ${libcVersion} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
152
+ if (libcFamily === detectLibc.MUSL) {
153
+ if (semverLessThan(libcVersion, '1.1.24')) {
154
+ handleError(new Error(`Use with musl ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
155
+ }
149
156
  }
150
157
  }
151
158
  // Node.js minimum version check
@@ -153,7 +160,6 @@ try {
153
160
  if (!semverSatisfies(process.versions.node, supportedNodeVersion)) {
154
161
  handleError(new Error(`Expected Node.js version ${supportedNodeVersion} but found ${process.versions.node}`));
155
162
  }
156
-
157
163
  // Download to per-process temporary file
158
164
  const tarFilename = ['libvips', minimumLibvipsVersionLabelled, platformAndArch].join('-') + '.tar.br';
159
165
  const tarPathCache = path.join(libvips.cachePath(), tarFilename);
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');
@@ -27,7 +30,7 @@ module.exports = function (log) {
27
30
  const proxyAuth = proxy.username && proxy.password
28
31
  ? `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`
29
32
  : null;
30
- log(`Via proxy ${proxy.protocol}://${proxy.hostname}:${proxy.port} ${proxyAuth ? 'with' : 'no'} credentials`);
33
+ log(`Via proxy ${proxy.protocol}//${proxy.hostname}:${proxy.port} ${proxyAuth ? 'with' : 'no'} credentials`);
31
34
  return tunnel({
32
35
  proxy: {
33
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');
package/lib/colour.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 color = require('color');
@@ -67,7 +70,8 @@ function grayscale (grayscale) {
67
70
  * Set the pipeline colourspace.
68
71
  *
69
72
  * The input image will be converted to the provided colourspace at the start of the pipeline.
70
- * All operations will use this colourspace before converting to the output colourspace, as defined by {@link toColourspace}.
73
+ * All operations will use this colourspace before converting to the output colourspace,
74
+ * as defined by {@link #tocolourspace|toColourspace}.
71
75
  *
72
76
  * This feature is experimental and has not yet been fully-tested with all operations.
73
77
  *
package/lib/composite.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');
@@ -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,8 +116,8 @@ 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.
@@ -124,14 +127,14 @@ const debuglog = util.debuglog('sharp');
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=false] - Set this to `true` to use sequential rather than random access where possible.
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.pages=1] - number of pages to extract for multi-page input (GIF, WebP, AVIF, TIFF, PDF), use -1 for all pages.
131
- * @param {number} [options.page=0] - page number to start extracting from for multi-page input (GIF, WebP, AVIF, TIFF, PDF), zero based.
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.
@@ -151,13 +154,14 @@ const debuglog = util.debuglog('sharp');
151
154
  * @param {string} [options.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.
152
155
  * @param {string} [options.text.font] - font name to render with.
153
156
  * @param {string} [options.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.
154
- * @param {number} [options.text.width=0] - integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.
155
- * @param {number} [options.text.height=0] - integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.
156
- * @param {string} [options.text.align='left'] - text alignment (`'left'`, `'centre'`, `'center'`, `'right'`).
157
+ * @param {number} [options.text.width=0] - Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.
158
+ * @param {number} [options.text.height=0] - Maximum integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.
159
+ * @param {string} [options.text.align='left'] - Alignment style for multi-line text (`'left'`, `'centre'`, `'center'`, `'right'`).
157
160
  * @param {boolean} [options.text.justify=false] - set this to true to apply justification to the text.
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: [],
@@ -212,6 +217,7 @@ const Sharp = function (input, options) {
212
217
  tintB: 128,
213
218
  flatten: false,
214
219
  flattenBackground: [0, 0, 0],
220
+ unflatten: false,
215
221
  negate: false,
216
222
  negateAlpha: true,
217
223
  medianSize: 0,
@@ -230,6 +236,8 @@ const Sharp = function (input, options) {
230
236
  gammaOut: 0,
231
237
  greyscale: false,
232
238
  normalise: false,
239
+ normaliseLower: 1,
240
+ normaliseUpper: 99,
233
241
  claheWidth: 0,
234
242
  claheHeight: 0,
235
243
  claheMaxSlope: 3,
@@ -291,7 +299,8 @@ const Sharp = function (input, options) {
291
299
  gifDither: 1,
292
300
  gifInterFrameMaxError: 0,
293
301
  gifInterPaletteMaxError: 3,
294
- gifReoptimise: false,
302
+ gifReuse: true,
303
+ gifProgressive: false,
295
304
  tiffQuality: 80,
296
305
  tiffCompression: 'jpeg',
297
306
  tiffPredictor: 'horizontal',