sharp 0.21.2 → 0.21.3

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.
@@ -11,7 +11,7 @@ If the overlay image contains an alpha channel then composition with premultipli
11
11
 
12
12
  ### Parameters
13
13
 
14
- - `overlay` **([Buffer][1] \| [String][2])** Buffer containing image data or String containing the path to an image file.
14
+ - `overlay` **([Buffer][1] \| [String][2])?** Buffer containing image data or String containing the path to an image file.
15
15
  - `options` **[Object][3]?**
16
16
  - `options.gravity` **[String][2]** gravity at which to place the overlay. (optional, default `'centre'`)
17
17
  - `options.top` **[Number][4]?** the pixel offset from the top edge.
@@ -9,9 +9,8 @@
9
9
  a String containing the path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
10
10
  JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
11
11
  - `options` **[Object][3]?** if present, is an Object with optional attributes.
12
- - `options.failOnError` **[Boolean][4]** by default apply a "best effort"
13
- to decode images, even if the data is corrupt or invalid. Set this flag to true
14
- if you'd rather halt processing and raise an error when loading invalid images. (optional, default `false`)
12
+ - `options.failOnError` **[Boolean][4]** by default halt processing and raise an error when loading invalid images.
13
+ Set this flag to `false` if you'd rather apply a "best effort" to decode images, even if the data is corrupt or invalid. (optional, default `true`)
15
14
  - `options.density` **[Number][5]** number representing the DPI for vector images. (optional, default `72`)
16
15
  - `options.page` **[Number][5]** page number to extract for multi-page input (GIF, TIFF) (optional, default `0`)
17
16
  - `options.raw` **[Object][3]?** describes raw pixel input image data. See `raw()` for pixel ordering.
package/docs/changelog.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  Requires libvips v8.7.0.
6
6
 
7
+ #### v0.21.3 - 19<sup>th</sup> January 2019
8
+
9
+ * Input image decoding now fails fast, set `failOnError` to change this behaviour.
10
+
11
+ * Failed filesystem-based input now separates missing file and invalid format errors.
12
+ [#1542](https://github.com/lovell/sharp/issues/1542)
13
+
7
14
  #### v0.21.2 - 13<sup>th</sup> January 2019
8
15
 
9
16
  * Ensure all metadata is removed from PNG output unless `withMetadata` used.
@@ -20,7 +20,8 @@ const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SH
20
20
 
21
21
  const fail = function (err) {
22
22
  npmLog.error('sharp', err.message);
23
- npmLog.error('sharp', 'Please see http://sharp.pixelplumbing.com/page/install');
23
+ npmLog.info('sharp', 'Attempting to build from source via node-gyp but this may fail due to the above error');
24
+ npmLog.info('sharp', 'Please see https://sharp.pixelplumbing.com/page/install for required dependencies');
24
25
  process.exit(1);
25
26
  };
26
27
 
package/lib/composite.js CHANGED
@@ -26,7 +26,7 @@ const is = require('./is');
26
26
  * // sharpened, with metadata, 90% quality WebP image data. Phew!
27
27
  * });
28
28
  *
29
- * @param {(Buffer|String)} overlay - Buffer containing image data or String containing the path to an image file.
29
+ * @param {(Buffer|String)} [overlay] - Buffer containing image data or String containing the path to an image file.
30
30
  * @param {Object} [options]
31
31
  * @param {String} [options.gravity='centre'] - gravity at which to place the overlay.
32
32
  * @param {Number} [options.top] - the pixel offset from the top edge.
@@ -61,9 +61,8 @@ const debuglog = util.debuglog('sharp');
61
61
  * a String containing the path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
62
62
  * JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
63
63
  * @param {Object} [options] - if present, is an Object with optional attributes.
64
- * @param {Boolean} [options.failOnError=false] - by default apply a "best effort"
65
- * to decode images, even if the data is corrupt or invalid. Set this flag to true
66
- * if you'd rather halt processing and raise an error when loading invalid images.
64
+ * @param {Boolean} [options.failOnError=true] - by default halt processing and raise an error when loading invalid images.
65
+ * Set this flag to `false` if you'd rather apply a "best effort" to decode images, even if the data is corrupt or invalid.
67
66
  * @param {Number} [options.density=72] - number representing the DPI for vector images.
68
67
  * @param {Number} [options.page=0] - page number to extract for multi-page input (GIF, TIFF)
69
68
  * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
package/lib/input.js CHANGED
@@ -9,7 +9,7 @@ const sharp = require('../build/Release/sharp.node');
9
9
  * @private
10
10
  */
11
11
  function _createInputDescriptor (input, inputOptions, containerOptions) {
12
- const inputDescriptor = { failOnError: false };
12
+ const inputDescriptor = { failOnError: true };
13
13
  if (is.string(input)) {
14
14
  // filesystem
15
15
  inputDescriptor.file = input;
package/lib/output.js CHANGED
@@ -32,7 +32,7 @@ const sharp = require('../build/Release/sharp.node');
32
32
  */
33
33
  function toFile (fileOut, callback) {
34
34
  if (!fileOut || fileOut.length === 0) {
35
- const errOutputInvalid = new Error('Invalid output');
35
+ const errOutputInvalid = new Error('Missing output file path');
36
36
  if (is.fn(callback)) {
37
37
  callback(errOutputInvalid);
38
38
  } else {
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 and TIFF images",
4
- "version": "0.21.2",
4
+ "version": "0.21.3",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -108,7 +108,7 @@
108
108
  "devDependencies": {
109
109
  "async": "^2.6.1",
110
110
  "cc": "^1.0.2",
111
- "decompress-zip": "^0.3.1",
111
+ "decompress-zip": "^0.3.2",
112
112
  "documentation": "^9.1.1",
113
113
  "exif-reader": "^1.0.2",
114
114
  "icc": "^1.0.0",
package/src/common.cc CHANGED
@@ -137,6 +137,7 @@ namespace sharp {
137
137
  case ImageType::VIPS: id = "v"; break;
138
138
  case ImageType::RAW: id = "raw"; break;
139
139
  case ImageType::UNKNOWN: id = "unknown"; break;
140
+ case ImageType::MISSING: id = "missing"; break;
140
141
  }
141
142
  return id;
142
143
  }
@@ -203,6 +204,10 @@ namespace sharp {
203
204
  } else if (EndsWith(loader, "Magick") || EndsWith(loader, "MagickFile")) {
204
205
  imageType = ImageType::MAGICK;
205
206
  }
207
+ } else {
208
+ if (EndsWith(vips::VError().what(), " not found\n")) {
209
+ imageType = ImageType::MISSING;
210
+ }
206
211
  }
207
212
  return imageType;
208
213
  }
@@ -269,6 +274,9 @@ namespace sharp {
269
274
  } else {
270
275
  // From filesystem
271
276
  imageType = DetermineImageType(descriptor->file.data());
277
+ if (imageType == ImageType::MISSING) {
278
+ throw vips::VError("Input file is missing");
279
+ }
272
280
  if (imageType != ImageType::UNKNOWN) {
273
281
  try {
274
282
  vips::VOption *option = VImage::option()
@@ -291,7 +299,7 @@ namespace sharp {
291
299
  throw vips::VError(std::string("Input file has corrupt header: ") + err.what());
292
300
  }
293
301
  } else {
294
- throw vips::VError("Input file is missing or of an unsupported image format");
302
+ throw vips::VError("Input file contains unsupported image format");
295
303
  }
296
304
  }
297
305
  }
package/src/common.h CHANGED
@@ -61,7 +61,7 @@ namespace sharp {
61
61
 
62
62
  InputDescriptor():
63
63
  buffer(nullptr),
64
- failOnError(FALSE),
64
+ failOnError(TRUE),
65
65
  bufferLength(0),
66
66
  density(72.0),
67
67
  rawChannels(0),
@@ -106,7 +106,8 @@ namespace sharp {
106
106
  FITS,
107
107
  VIPS,
108
108
  RAW,
109
- UNKNOWN
109
+ UNKNOWN,
110
+ MISSING
110
111
  };
111
112
 
112
113
  // How many tasks are in the queue?