sharp 0.25.0 → 0.25.4

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
@@ -1,10 +1,6 @@
1
1
  # sharp
2
2
 
3
- <img src="https://raw.githubusercontent.com/lovell/sharp/master/docs/image/sharp-logo.svg?sanitize=true" width="160" height="160" alt="sharp logo" align="right">
4
-
5
- ```sh
6
- npm install sharp
7
- ```
3
+ <img src="https://cdn.jsdelivr.net/gh/lovell/sharp@master/docs/image/sharp-logo.svg" width="160" height="160" alt="sharp logo" align="right">
8
4
 
9
5
  The typical use case for this high speed Node.js module
10
6
  is to convert large images in common formats to
@@ -20,11 +16,15 @@ Lanczos resampling ensures quality is not sacrificed for speed.
20
16
  As well as image resizing, operations such as
21
17
  rotation, extraction, compositing and gamma correction are available.
22
18
 
23
- Most modern macOS, Windows and Linux systems running Node.js v10.16.0+
19
+ Most modern macOS, Windows and Linux systems running Node.js v10+
24
20
  do not require any additional install or runtime dependencies.
25
21
 
26
22
  ## Examples
27
23
 
24
+ ```sh
25
+ npm install sharp
26
+ ```
27
+
28
28
  ```javascript
29
29
  const sharp = require('sharp');
30
30
  ```
@@ -85,6 +85,7 @@ readableStream
85
85
  ```
86
86
 
87
87
  [![Test Coverage](https://coveralls.io/repos/lovell/sharp/badge.svg?branch=master)](https://coveralls.io/r/lovell/sharp?branch=master)
88
+ [![N-API v3](https://img.shields.io/badge/N--API-v3-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix)
88
89
 
89
90
  ### Documentation
90
91
 
package/binding.gyp CHANGED
@@ -29,10 +29,22 @@
29
29
  'Release': {
30
30
  'msvs_settings': {
31
31
  'VCCLCompilerTool': {
32
- 'ExceptionHandling': 1
32
+ 'ExceptionHandling': 1,
33
+ 'WholeProgramOptimization': 'true'
34
+ },
35
+ 'VCLibrarianTool': {
36
+ 'AdditionalOptions': [
37
+ '/LTCG:INCREMENTAL'
38
+ ]
33
39
  },
34
40
  'VCLinkerTool': {
35
- 'ImageHasSafeExceptionHandlers': 'false'
41
+ 'ImageHasSafeExceptionHandlers': 'false',
42
+ 'OptimizeReferences': 2,
43
+ 'EnableCOMDATFolding': 2,
44
+ 'LinkIncremental': 1,
45
+ 'AdditionalOptions': [
46
+ '/LTCG:INCREMENTAL'
47
+ ]
36
48
  }
37
49
  },
38
50
  'msvs_disabled_warnings': [
@@ -47,6 +59,9 @@
47
59
  ]
48
60
  }, {
49
61
  'target_name': 'sharp',
62
+ 'defines': [
63
+ 'NAPI_VERSION=3'
64
+ ],
50
65
  'dependencies': [
51
66
  '<!(node -p "require(\'node-addon-api\').gyp")',
52
67
  'libvips-cpp'
@@ -118,7 +133,7 @@
118
133
  '../vendor/lib/libglib-2.0.0.dylib',
119
134
  '../vendor/lib/libgobject-2.0.0.dylib',
120
135
  # Ensure runtime linking is relative to sharp.node
121
- '-rpath \'@loader_path/../../vendor/lib\''
136
+ '-Wl,-s -rpath \'@loader_path/../../vendor/lib\''
122
137
  ]
123
138
  }],
124
139
  ['OS == "linux"', {
@@ -161,7 +176,7 @@
161
176
  '../vendor/lib/libxml2.so',
162
177
  '../vendor/lib/libz.so',
163
178
  # Ensure runtime linking is relative to sharp.node
164
- '-Wl,--disable-new-dtags -Wl,-rpath=\'$${ORIGIN}/../../vendor/lib\''
179
+ '-Wl,-s -Wl,--disable-new-dtags -Wl,-rpath=\'$${ORIGIN}/../../vendor/lib\''
165
180
  ]
166
181
  }]
167
182
  ]
@@ -201,10 +216,22 @@
201
216
  ['OS == "win"', {
202
217
  'msvs_settings': {
203
218
  'VCCLCompilerTool': {
204
- 'ExceptionHandling': 1
219
+ 'ExceptionHandling': 1,
220
+ 'WholeProgramOptimization': 'true'
221
+ },
222
+ 'VCLibrarianTool': {
223
+ 'AdditionalOptions': [
224
+ '/LTCG:INCREMENTAL'
225
+ ]
205
226
  },
206
227
  'VCLinkerTool': {
207
- 'ImageHasSafeExceptionHandlers': 'false'
228
+ 'ImageHasSafeExceptionHandlers': 'false',
229
+ 'OptimizeReferences': 2,
230
+ 'EnableCOMDATFolding': 2,
231
+ 'LinkIncremental': 1,
232
+ 'AdditionalOptions': [
233
+ '/LTCG:INCREMENTAL'
234
+ ]
208
235
  }
209
236
  },
210
237
  'msvs_disabled_warnings': [
@@ -6,7 +6,8 @@ const path = require('path');
6
6
  const libvips = require('../lib/libvips');
7
7
  const npmLog = require('npmlog');
8
8
 
9
- if (process.platform === 'win32') {
9
+ const platform = process.env.npm_config_platform || process.platform;
10
+ if (platform === 'win32') {
10
11
  const buildDir = path.join(__dirname, '..', 'build');
11
12
  const buildReleaseDir = path.join(buildDir, 'Release');
12
13
  npmLog.info('sharp', `Creating ${buildReleaseDir}`);
@@ -21,7 +21,8 @@ const minimumGlibcVersionByArch = {
21
21
  };
22
22
 
23
23
  const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
24
- const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `https://github.com/lovell/sharp-libvips/releases/download/v${minimumLibvipsVersionLabelled}/`;
24
+ const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
25
+ const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
25
26
 
26
27
  const fail = function (err) {
27
28
  npmLog.error('sharp', err.message);
package/lib/channel.js CHANGED
@@ -60,22 +60,19 @@ function ensureAlpha () {
60
60
  * // green.jpg is a greyscale image containing the green channel of the input
61
61
  * });
62
62
  *
63
- * @param {Number|String} channel - zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively.
63
+ * @param {number|string} channel - zero-indexed channel/band number to extract, or `red`, `green`, `blue` or `alpha`.
64
64
  * @returns {Sharp}
65
65
  * @throws {Error} Invalid channel
66
66
  */
67
67
  function extractChannel (channel) {
68
- if (channel === 'red') {
69
- channel = 0;
70
- } else if (channel === 'green') {
71
- channel = 1;
72
- } else if (channel === 'blue') {
73
- channel = 2;
68
+ const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };
69
+ if (Object.keys(channelMap).includes(channel)) {
70
+ channel = channelMap[channel];
74
71
  }
75
72
  if (is.integer(channel) && is.inRange(channel, 0, 4)) {
76
73
  this.options.extractChannel = channel;
77
74
  } else {
78
- throw is.invalidParameterError('channel', 'integer or one of: red, green, blue', channel);
75
+ throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);
79
76
  }
80
77
  return this;
81
78
  }
@@ -91,7 +88,7 @@ function extractChannel (channel) {
91
88
  * Buffers may be any of the image formats supported by sharp: JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data.
92
89
  * For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.
93
90
  *
94
- * @param {Array<String|Buffer>|String|Buffer} images - one or more images (file paths, Buffers).
91
+ * @param {Array<string|Buffer>|string|Buffer} images - one or more images (file paths, Buffers).
95
92
  * @param {Object} options - image options, see `sharp()` constructor.
96
93
  * @returns {Sharp}
97
94
  * @throws {Error} Invalid parameters
@@ -119,7 +116,7 @@ function joinChannel (images, options) {
119
116
  * // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`.
120
117
  * });
121
118
  *
122
- * @param {String} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
119
+ * @param {string} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
123
120
  * @returns {Sharp}
124
121
  * @throws {Error} Invalid parameters
125
122
  */
package/lib/colour.js CHANGED
@@ -19,7 +19,7 @@ const colourspace = {
19
19
  * Tint the image using the provided chroma while preserving the image luminance.
20
20
  * An alpha channel may be present and will be unchanged by the operation.
21
21
  *
22
- * @param {String|Object} rgb - parsed by the [color](https://www.npmjs.org/package/color) module to extract chroma values.
22
+ * @param {string|Object} rgb - parsed by the [color](https://www.npmjs.org/package/color) module to extract chroma values.
23
23
  * @returns {Sharp}
24
24
  * @throws {Error} Invalid parameter
25
25
  */
@@ -57,7 +57,7 @@ function grayscale (grayscale) {
57
57
  /**
58
58
  * Set the output colourspace.
59
59
  * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
60
- * @param {String} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568)
60
+ * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568)
61
61
  * @returns {Sharp}
62
62
  * @throws {Error} Invalid parameters
63
63
  */
@@ -71,7 +71,7 @@ function toColourspace (colourspace) {
71
71
 
72
72
  /**
73
73
  * Alternative spelling of `toColourspace`.
74
- * @param {String} [colorspace] - output colorspace.
74
+ * @param {string} [colorspace] - output colorspace.
75
75
  * @returns {Sharp}
76
76
  * @throws {Error} Invalid parameters
77
77
  */
@@ -82,8 +82,8 @@ function toColorspace (colorspace) {
82
82
  /**
83
83
  * Update a colour attribute of the this.options Object.
84
84
  * @private
85
- * @param {String} key
86
- * @param {String|Object} value
85
+ * @param {string} key
86
+ * @param {string|Object} value
87
87
  * @throws {Error} Invalid value
88
88
  */
89
89
  function _setBackgroundColourOption (key, value) {
package/lib/composite.js CHANGED
@@ -72,7 +72,7 @@ const blend = {
72
72
  * });
73
73
  *
74
74
  * @param {Object[]} images - Ordered list of images to composite
75
- * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see bellow)
75
+ * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see below)
76
76
  * @param {Object} [images[].input.create] - describes a blank overlay to be created.
77
77
  * @param {Number} [images[].input.create.width]
78
78
  * @param {Number} [images[].input.create.height]
@@ -100,10 +100,7 @@ function composite (images) {
100
100
  if (!is.object(image)) {
101
101
  throw is.invalidParameterError('image to composite', 'object', image);
102
102
  }
103
- const { raw, density, limitInputPixels, sequentialRead } = image;
104
- const inputOptions = [raw, density, limitInputPixels, sequentialRead].some(is.defined)
105
- ? { raw, density, limitInputPixels, sequentialRead }
106
- : undefined;
103
+ const inputOptions = this._inputOptionsFromObject(image);
107
104
  const composite = {
108
105
  input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),
109
106
  blend: 'over',
@@ -38,15 +38,20 @@ try {
38
38
  const debuglog = util.debuglog('sharp');
39
39
 
40
40
  /**
41
- * @constructs sharp
42
- *
43
41
  * Constructor factory to create an instance of `sharp`, to which further methods are chained.
44
42
  *
45
43
  * JPEG, PNG, WebP or TIFF format image data can be streamed out from this object.
46
44
  * When using Stream based output, derived attributes are available from the `info` event.
47
45
  *
46
+ * Non-critical problems encountered during processing are emitted as `warning` events.
47
+ *
48
48
  * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
49
49
  *
50
+ * @constructs Sharp
51
+ *
52
+ * @emits Sharp#info
53
+ * @emits Sharp#warning
54
+ *
50
55
  * @example
51
56
  * sharp('input.jpg')
52
57
  * .resize(300, 200)
@@ -81,30 +86,31 @@ const debuglog = util.debuglog('sharp');
81
86
  * .toBuffer()
82
87
  * .then( ... );
83
88
  *
84
- * @param {(Buffer|String)} [input] - if present, can be
89
+ * @param {(Buffer|string)} [input] - if present, can be
85
90
  * a Buffer containing JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data, or
86
91
  * a String containing the filesystem path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
87
92
  * JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
88
93
  * @param {Object} [options] - if present, is an Object with optional attributes.
89
- * @param {Boolean} [options.failOnError=true] - by default halt processing and raise an error when loading invalid images.
94
+ * @param {boolean} [options.failOnError=true] - by default halt processing and raise an error when loading invalid images.
90
95
  * Set this flag to `false` if you'd rather apply a "best effort" to decode images, even if the data is corrupt or invalid.
91
- * @param {Number|Boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels
96
+ * @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels
92
97
  * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.
93
98
  * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).
94
- * @param {Boolean} [options.sequentialRead=false] - Set this to `true` to use sequential rather than random access where possible.
99
+ * @param {boolean} [options.sequentialRead=false] - Set this to `true` to use sequential rather than random access where possible.
95
100
  * This can reduce memory usage and might improve performance on some systems.
96
- * @param {Number} [options.density=72] - number representing the DPI for vector images.
97
- * @param {Number} [options.pages=1] - number of pages to extract for multi-page input (GIF, TIFF, PDF), use -1 for all pages.
98
- * @param {Number} [options.page=0] - page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based.
101
+ * @param {number} [options.density=72] - number representing the DPI for vector images.
102
+ * @param {number} [options.pages=1] - number of pages to extract for multi-page input (GIF, TIFF, PDF), use -1 for all pages.
103
+ * @param {number} [options.page=0] - page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based.
104
+ * @param {number} [options.level=0] - level to extract from a multi-level input (OpenSlide), zero based.
99
105
  * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
100
- * @param {Number} [options.raw.width]
101
- * @param {Number} [options.raw.height]
102
- * @param {Number} [options.raw.channels] - 1-4
106
+ * @param {number} [options.raw.width]
107
+ * @param {number} [options.raw.height]
108
+ * @param {number} [options.raw.channels] - 1-4
103
109
  * @param {Object} [options.create] - describes a new image to be created.
104
- * @param {Number} [options.create.width]
105
- * @param {Number} [options.create.height]
106
- * @param {Number} [options.create.channels] - 3-4
107
- * @param {String|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
110
+ * @param {number} [options.create.width]
111
+ * @param {number} [options.create.height]
112
+ * @param {number} [options.create.channels] - 3-4
113
+ * @param {string|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
108
114
  * @returns {Sharp}
109
115
  * @throws {Error} Invalid parameters
110
116
  */
@@ -229,7 +235,10 @@ const Sharp = function (input, options) {
229
235
  linearA: 1,
230
236
  linearB: 0,
231
237
  // Function to notify of libvips warnings
232
- debuglog: debuglog,
238
+ debuglog: warning => {
239
+ this.emit('warning', warning);
240
+ debuglog(warning);
241
+ },
233
242
  // Function to notify of queue length changes
234
243
  queueListener: function (queueLength) {
235
244
  Sharp.queue.emit('change', queueLength);
@@ -253,6 +262,54 @@ util.inherits(Sharp, stream.Duplex);
253
262
  * // firstWritableStream receives auto-rotated, resized readableStream
254
263
  * // secondWritableStream receives auto-rotated, extracted region of readableStream
255
264
  *
265
+ * @example
266
+ * // Create a pipeline that will download an image, resize it and format it to different files
267
+ * // Using Promises to know when the pipeline is complete
268
+ * const fs = require("fs");
269
+ * const got = require("got");
270
+ * const sharpStream = sharp({
271
+ * failOnError: false
272
+ * });
273
+ *
274
+ * const promises = [];
275
+ *
276
+ * promises.push(
277
+ * sharpStream
278
+ * .clone()
279
+ * .jpeg({ quality: 100 })
280
+ * .toFile("originalFile.jpg")
281
+ * );
282
+ *
283
+ * promises.push(
284
+ * sharpStream
285
+ * .clone()
286
+ * .resize({ width: 500 })
287
+ * .jpeg({ quality: 80 })
288
+ * .toFile("optimized-500.jpg")
289
+ * );
290
+ *
291
+ * promises.push(
292
+ * sharpStream
293
+ * .clone()
294
+ * .resize({ width: 500 })
295
+ * .webp({ quality: 80 })
296
+ * .toFile("optimized-500.webp")
297
+ * );
298
+ *
299
+ * // https://github.com/sindresorhus/got#gotstreamurl-options
300
+ * got.stream("https://www.example.com/some-file.jpg").pipe(sharpStream);
301
+ *
302
+ * Promise.all(promises)
303
+ * .then(res => { console.log("Done!", res); })
304
+ * .catch(err => {
305
+ * console.error("Error processing files, let's clean it up", err);
306
+ * try {
307
+ * fs.unlinkSync("originalFile.jpg");
308
+ * fs.unlinkSync("optimized-500.jpg");
309
+ * fs.unlinkSync("optimized-500.webp");
310
+ * } catch (e) {}
311
+ * });
312
+ *
256
313
  * @returns {Sharp}
257
314
  */
258
315
  function clone () {
package/lib/input.js CHANGED
@@ -4,6 +4,17 @@ const color = require('color');
4
4
  const is = require('./is');
5
5
  const sharp = require('../build/Release/sharp.node');
6
6
 
7
+ /**
8
+ * Extract input options, if any, from an object.
9
+ * @private
10
+ */
11
+ function _inputOptionsFromObject (obj) {
12
+ const { raw, density, limitInputPixels, sequentialRead, failOnError } = obj;
13
+ return [raw, density, limitInputPixels, sequentialRead, failOnError].some(is.defined)
14
+ ? { raw, density, limitInputPixels, sequentialRead, failOnError }
15
+ : undefined;
16
+ }
17
+
7
18
  /**
8
19
  * Create Object containing input and input-related options.
9
20
  * @private
@@ -23,12 +34,12 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
23
34
  } else if (is.plainObject(input) && !is.defined(inputOptions)) {
24
35
  // Plain Object descriptor, e.g. create
25
36
  inputOptions = input;
26
- if (is.plainObject(inputOptions.raw) || is.bool(inputOptions.failOnError)) {
27
- // Raw Stream
37
+ if (_inputOptionsFromObject(inputOptions)) {
38
+ // Stream with options
28
39
  inputDescriptor.buffer = [];
29
40
  }
30
41
  } else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {
31
- // Stream
42
+ // Stream without options
32
43
  inputDescriptor.buffer = [];
33
44
  } else {
34
45
  throw new Error(`Unsupported input '${input}' of type ${typeof input}${
@@ -102,6 +113,14 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
102
113
  throw is.invalidParameterError('page', 'integer between 0 and 100000', inputOptions.page);
103
114
  }
104
115
  }
116
+ // Multi-level input (OpenSlide)
117
+ if (is.defined(inputOptions.level)) {
118
+ if (is.integer(inputOptions.level) && is.inRange(inputOptions.level, 0, 256)) {
119
+ inputDescriptor.level = inputOptions.level;
120
+ } else {
121
+ throw is.invalidParameterError('level', 'integer between 0 and 256', inputOptions.level);
122
+ }
123
+ }
105
124
  // Create new image
106
125
  if (is.defined(inputOptions.create)) {
107
126
  if (
@@ -136,7 +155,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
136
155
  * Handle incoming Buffer chunk on Writable Stream.
137
156
  * @private
138
157
  * @param {Buffer} chunk
139
- * @param {String} encoding - unused
158
+ * @param {string} encoding - unused
140
159
  * @param {Function} callback
141
160
  */
142
161
  function _write (chunk, encoding, callback) {
@@ -172,7 +191,7 @@ function _flattenBufferIn () {
172
191
  /**
173
192
  * Are we expecting Stream-based input?
174
193
  * @private
175
- * @returns {Boolean}
194
+ * @returns {boolean}
176
195
  */
177
196
  function _isStreamInput () {
178
197
  return Array.isArray(this.options.input.buffer);
@@ -197,6 +216,7 @@ function _isStreamInput () {
197
216
  * - `loop`: Number of times to loop an animated image, zero refers to a continuous loop.
198
217
  * - `delay`: Delay in ms between each page in an animated image, provided as an array of integers.
199
218
  * - `pagePrimary`: Number of the primary page in a HEIF image
219
+ * - `levels`: Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide
200
220
  * - `hasProfile`: Boolean indicating the presence of an embedded ICC profile
201
221
  * - `hasAlpha`: Boolean indicating the presence of an alpha transparency channel
202
222
  * - `orientation`: Number value of the EXIF Orientation header, if present
@@ -279,6 +299,7 @@ function metadata (callback) {
279
299
  * - `maxY` (y-coordinate of one of the pixel where the maximum lies)
280
300
  * - `isOpaque`: Is the image fully opaque? Will be `true` if the image has no alpha channel or if every pixel is fully opaque.
281
301
  * - `entropy`: Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental)
302
+ * - `sharpness`: Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental)
282
303
  *
283
304
  * @example
284
305
  * const image = sharp(inputJpg);
@@ -288,6 +309,9 @@ function metadata (callback) {
288
309
  * // stats contains the channel-wise statistics array and the isOpaque value
289
310
  * });
290
311
  *
312
+ * @example
313
+ * const { entropy, sharpness } = await sharp(input).stats();
314
+ *
291
315
  * @param {Function} [callback] - called with the arguments `(err, stats)`
292
316
  * @returns {Promise<Object>}
293
317
  */
@@ -337,6 +361,7 @@ function stats (callback) {
337
361
  module.exports = function (Sharp) {
338
362
  Object.assign(Sharp.prototype, {
339
363
  // Private
364
+ _inputOptionsFromObject,
340
365
  _createInputDescriptor,
341
366
  _write,
342
367
  _flattenBufferIn,
package/lib/is.js CHANGED
@@ -21,7 +21,7 @@ const object = function (val) {
21
21
  * @private
22
22
  */
23
23
  const plainObject = function (val) {
24
- return object(val) && Object.prototype.toString.call(val) === '[object Object]';
24
+ return Object.prototype.toString.call(val) === '[object Object]';
25
25
  };
26
26
 
27
27
  /**
@@ -45,7 +45,7 @@ const bool = function (val) {
45
45
  * @private
46
46
  */
47
47
  const buffer = function (val) {
48
- return object(val) && val instanceof Buffer;
48
+ return val instanceof Buffer;
49
49
  };
50
50
 
51
51
  /**
@@ -69,7 +69,7 @@ const number = function (val) {
69
69
  * @private
70
70
  */
71
71
  const integer = function (val) {
72
- return number(val) && val % 1 === 0;
72
+ return Number.isInteger(val);
73
73
  };
74
74
 
75
75
  /**
@@ -85,14 +85,14 @@ const inRange = function (val, min, max) {
85
85
  * @private
86
86
  */
87
87
  const inArray = function (val, list) {
88
- return list.indexOf(val) !== -1;
88
+ return list.includes(val);
89
89
  };
90
90
 
91
91
  /**
92
92
  * Create an Error with a message relating to an invalid parameter.
93
93
  *
94
- * @param {String} name - parameter name.
95
- * @param {String} expected - description of the type/value/range expected.
94
+ * @param {string} name - parameter name.
95
+ * @param {string} expected - description of the type/value/range expected.
96
96
  * @param {*} actual - the value received.
97
97
  * @returns {Error} Containing the formatted message.
98
98
  * @private
package/lib/libvips.js CHANGED
@@ -65,7 +65,7 @@ const hasVendoredLibvips = function () {
65
65
  if (currentPlatformId === vendorPlatformId) {
66
66
  return true;
67
67
  } else {
68
- throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.`);
68
+ throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the '${currentPlatformId}' platform.`);
69
69
  }
70
70
  } else {
71
71
  return false;