sharp 0.17.2 → 0.18.2

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/docs/changelog.md CHANGED
@@ -1,9 +1,112 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.18 - "*ridge*"
4
+
5
+ Requires libvips v8.5.5.
6
+
7
+ #### v0.18.2 - 1<sup>st</sup> July 2017
8
+
9
+ * Expose libvips' xres and yres properties for TIFF output.
10
+ [#828](https://github.com/lovell/sharp/pull/828)
11
+ [@YvesBos](https://github.com/YvesBos)
12
+
13
+ * Ensure flip and flop operations work with auto-rotate.
14
+ [#837](https://github.com/lovell/sharp/issues/837)
15
+ [@rexxars](https://github.com/rexxars)
16
+
17
+ * Allow binary download URL override via SHARP_DIST_BASE_URL env variable.
18
+ [#841](https://github.com/lovell/sharp/issues/841)
19
+
20
+ * Add support for Solus Linux.
21
+ [#857](https://github.com/lovell/sharp/pull/857)
22
+ [@ekremkaraca](https://github.com/ekremkaraca)
23
+
24
+ #### v0.18.1 - 30<sup>th</sup> May 2017
25
+
26
+ * Remove regression from #781 that could cause incorrect shrink calculation.
27
+ [#831](https://github.com/lovell/sharp/issues/831)
28
+ [@suprMax](https://github.com/suprMax)
29
+
30
+ #### v0.18.0 - 30<sup>th</sup> May 2017
31
+
32
+ * Remove the previously-deprecated output format "option" functions:
33
+ quality, progressive, compressionLevel, withoutAdaptiveFiltering,
34
+ withoutChromaSubsampling, trellisQuantisation, trellisQuantization,
35
+ overshootDeringing, optimiseScans and optimizeScans.
36
+
37
+ * Ensure maximum output dimensions are based on the format to be used.
38
+ [#176](https://github.com/lovell/sharp/issues/176)
39
+ [@stephanebachelier](https://github.com/stephanebachelier)
40
+
41
+ * Avoid costly (un)premultiply when using overlayWith without alpha channel.
42
+ [#573](https://github.com/lovell/sharp/issues/573)
43
+ [@strarsis](https://github.com/strarsis)
44
+
45
+ * Include pixel depth (e.g. "uchar") when reading metadata.
46
+ [#577](https://github.com/lovell/sharp/issues/577)
47
+ [@moedusa](https://github.com/moedusa)
48
+
49
+ * Add support for Buffer and Stream-based TIFF output.
50
+ [#587](https://github.com/lovell/sharp/issues/587)
51
+ [@strarsis](https://github.com/strarsis)
52
+
53
+ * Expose warnings from libvips via NODE_DEBUG=sharp environment variable.
54
+ [#607](https://github.com/lovell/sharp/issues/607)
55
+ [@puzrin](https://github.com/puzrin)
56
+
57
+ * Switch to the libvips implementation of "attention" and "entropy" crop strategies.
58
+ [#727](https://github.com/lovell/sharp/issues/727)
59
+
60
+ * Improve performance and accuracy of nearest neighbour integral upsampling.
61
+ [#752](https://github.com/lovell/sharp/issues/752)
62
+ [@MrIbby](https://github.com/MrIbby)
63
+
64
+ * Constructor single argument API: allow plain object, reject null/undefined.
65
+ [#768](https://github.com/lovell/sharp/issues/768)
66
+ [@kub1x](https://github.com/kub1x)
67
+
68
+ * Ensure ARM64 pre-built binaries use correct C++11 ABI version.
69
+ [#772](https://github.com/lovell/sharp/issues/772)
70
+ [@ajiratech2](https://github.com/ajiratech2)
71
+
72
+ * Prevent aliasing by using dynamic values for shrink(-on-load).
73
+ [#781](https://github.com/lovell/sharp/issues/781)
74
+ [@kleisauke](https://github.com/kleisauke)
75
+
76
+ * Expose libvips' "squash" parameter to enable 1-bit TIFF output.
77
+ [#783](https://github.com/lovell/sharp/pull/783)
78
+ [@YvesBos](https://github.com/YvesBos)
79
+
80
+ * Add support for rotation using any multiple of +/-90 degrees.
81
+ [#791](https://github.com/lovell/sharp/pull/791)
82
+ [@ncoden](https://github.com/ncoden)
83
+
84
+ * Add "jpg" alias to toFormat as shortened form of "jpeg".
85
+ [#814](https://github.com/lovell/sharp/pull/814)
86
+ [@jingsam](https://github.com/jingsam)
87
+
3
88
  ### v0.17 - "*quill*"
4
89
 
5
90
  Requires libvips v8.4.2.
6
91
 
92
+ #### v0.17.3 - 1<sup>st</sup> April 2017
93
+
94
+ * Allow toBuffer to optionally resolve a Promise with both info and data.
95
+ [#143](https://github.com/lovell/sharp/issues/143)
96
+ [@salzhrani](https://github.com/salzhrani)
97
+
98
+ * Create blank image of given width, height, channels and background.
99
+ [#470](https://github.com/lovell/sharp/issues/470)
100
+ [@pjarts](https://github.com/pjarts)
101
+
102
+ * Add support for the "nearest" kernel for image reductions.
103
+ [#732](https://github.com/lovell/sharp/pull/732)
104
+ [@alice0meta](https://github.com/alice0meta)
105
+
106
+ * Add support for TIFF compression and predictor options.
107
+ [#738](https://github.com/lovell/sharp/pull/738)
108
+ [@kristojorg](https://github.com/kristojorg)
109
+
7
110
  #### v0.17.2 - 11<sup>th</sup> February 2017
8
111
 
9
112
  * Ensure Readable side of Stream can start flowing after Writable side has finished.
package/docs/index.md CHANGED
@@ -22,7 +22,7 @@ the installation of any external runtime dependencies.
22
22
 
23
23
  This module supports reading JPEG, PNG, WebP, TIFF, GIF and SVG images.
24
24
 
25
- Output images can be in JPEG, PNG and WebP formats as well as uncompressed raw pixel data.
25
+ Output images can be in JPEG, PNG, WebP and TIFF formats as well as uncompressed raw pixel data.
26
26
 
27
27
  Streams, Buffer objects and the filesystem can be used for input and output.
28
28
 
@@ -97,6 +97,9 @@ the help and code contributions of the following people:
97
97
  * [Matthias Thoemmes](https://github.com/cmtt)
98
98
  * [Patrick Paskaris](https://github.com/ppaskaris)
99
99
  * [Jérémy Lal](https://github.com/kapouer)
100
+ * [Alice Monday](https://github.com/alice0meta)
101
+ * [Kristo Jorgenson](https://github.com/kristojorg)
102
+ * [Yves Bos](https://github.com/YvesBos)
100
103
 
101
104
  Thank you!
102
105
 
package/docs/install.md CHANGED
@@ -10,9 +10,9 @@ yarn add sharp
10
10
 
11
11
  ### Prerequisites
12
12
 
13
- * Node v4+
13
+ * Node v4.5.0+
14
14
  * C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+
15
- * [node-gyp](https://github.com/TooTallNate/node-gyp#installation) and its dependencies
15
+ * [node-gyp](https://github.com/TooTallNate/node-gyp#installation) and its dependencies (includes Python)
16
16
 
17
17
  ### Linux
18
18
 
@@ -20,18 +20,19 @@ yarn add sharp
20
20
  [![Linux Build Status](https://circleci.com/gh/lovell/sharp.svg?style=svg&circle-token=6cb6d1d287a51af83722b19ed8885377fbc85e5c)](https://circleci.com/gh/lovell/sharp)
21
21
 
22
22
  libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`.
23
- This involves an automated HTTPS download of approximately 6.5MB.
23
+ This involves an automated HTTPS download of approximately 7MB.
24
24
 
25
25
  Most recent Linux-based operating systems with glibc running on x64 and ARMv6+ CPUs should "just work", e.g.:
26
26
 
27
27
  * Debian 7, 8
28
28
  * Ubuntu 12.04, 14.04, 16.04
29
29
  * Centos 7
30
- * Fedora 23, 24
30
+ * Fedora
31
31
  * openSUSE 13.2
32
32
  * Archlinux
33
33
  * Raspbian Jessie
34
34
  * Amazon Linux 2016.03, 2016.09
35
+ * Solus
35
36
 
36
37
  To use a globally-installed version of libvips instead of the provided binaries,
37
38
  make sure it is at least the version listed under `config.libvips` in the `package.json` file
@@ -48,8 +49,17 @@ it is recommended to install a system-wide installation of libvips from source:
48
49
 
49
50
  https://github.com/jcupitt/libvips#building-libvips-from-a-source-tarball
50
51
 
51
- For Linux-based operating systems such as Alpine that use musl libc,
52
- the smaller stack size means libvips' cache should be disabled
52
+ #### Alpine Linux
53
+
54
+ libvips is available in the
55
+ [testing repository](https://pkgs.alpinelinux.org/packages?name=vips-dev):
56
+
57
+ ```sh
58
+ apk add vips-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
59
+ ```
60
+
61
+ The smaller stack size of musl libc means
62
+ libvips may need to be used without a cache
53
63
  via `sharp.cache(false)` to avoid a stack overflow.
54
64
 
55
65
  ### Mac OS
@@ -57,7 +67,7 @@ via `sharp.cache(false)` to avoid a stack overflow.
57
67
  [![OS X 10.9.5 Build Status](https://travis-ci.org/lovell/sharp.png?branch=master)](https://travis-ci.org/lovell/sharp)
58
68
 
59
69
  libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`.
60
- This involves an automated HTTPS download of approximately 6.3MB.
70
+ This involves an automated HTTPS download of approximately 7MB.
61
71
 
62
72
  To use your own version of libvips instead of the provided binaries, make sure it is
63
73
  at least the version listed under `config.libvips` in the `package.json` file and
@@ -68,7 +78,7 @@ that it can be located using `pkg-config --modversion vips-cpp`.
68
78
  [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/pgtul704nkhhg6sg)](https://ci.appveyor.com/project/lovell/sharp)
69
79
 
70
80
  libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
71
- This involves an automated HTTPS download of approximately 9MB.
81
+ This involves an automated HTTPS download of approximately 11MB.
72
82
 
73
83
  Only 64-bit (x64) `node.exe` is supported.
74
84
 
@@ -83,9 +93,11 @@ cd /usr/ports/graphics/vips/ && make install clean
83
93
 
84
94
  ### Heroku
85
95
 
86
- [Alessandro Tagliapietra](https://github.com/alex88) maintains an
87
- [Heroku buildpack for libvips](https://github.com/alex88/heroku-buildpack-vips)
88
- and its dependencies.
96
+ libvips and its dependencies are fetched and stored within `node_modules\sharp\vendor` during `npm install`.
97
+ This involves an automated HTTPS download of approximately 7MB.
98
+
99
+ Set [NODE_MODULES_CACHE](https://devcenter.heroku.com/articles/nodejs-support#cache-behavior)
100
+ to `false` when using the `yarn` package manager.
89
101
 
90
102
  ### Docker
91
103
 
@@ -103,6 +115,13 @@ docker pull marcbachmann/libvips
103
115
  docker pull wjordan/libvips
104
116
  ```
105
117
 
118
+ [Tailor Brands](https://github.com/TailorBrands) maintain
119
+ [Debian-based Dockerfiles for libvips and nodejs](https://github.com/TailorBrands/docker-libvips).
120
+
121
+ ```sh
122
+ docker pull tailor/docker-libvips
123
+ ```
124
+
106
125
  ### AWS Lambda
107
126
 
108
127
  In order to use sharp on AWS Lambda, you need to [create a deployment package](http://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html). Because sharp
@@ -135,7 +154,6 @@ You can now download your deployment ZIP using `scp` and upload it to Lambda. Be
135
154
  * [gulp-responsive](https://www.npmjs.com/package/gulp-responsive)
136
155
  * [grunt-sharp](https://www.npmjs.com/package/grunt-sharp)
137
156
 
138
-
139
157
  ### CLI tools
140
158
 
141
159
  * [sharp-cli](https://www.npmjs.com/package/sharp-cli)
@@ -175,16 +193,27 @@ configuration file to prevent the use of coders known to be vulnerable.
175
193
  Set the `MAGICK_CONFIGURE_PATH` environment variable
176
194
  to the directory containing the `policy.xml` file.
177
195
 
178
- ### Licences
196
+ ### Pre-compiled libvips binaries
179
197
 
180
198
  If a global installation of libvips that meets the
181
199
  minimum version requirement cannot be found,
182
- this module will download a pre-compiled bundle of libvips
200
+ this module will attempt to download a pre-compiled bundle of libvips
183
201
  and its dependencies on Linux and Windows machines.
184
202
 
185
203
  Should you need to manually download and inspect these files,
186
204
  you can do so via https://dl.bintray.com/lovell/sharp/
187
205
 
206
+ Should you wish to install these from your own location,
207
+ set the `SHARP_DIST_BASE_URL` environment variable, e.g.
208
+
209
+ ```sh
210
+ SHARP_DIST_BASE_URL="https://hostname/path/" npm install sharp
211
+ ```
212
+
213
+ to use `https://hostname/path/libvips-x.y.z-platform.tar.gz`.
214
+
215
+ ### Licences
216
+
188
217
  This module is licensed under the terms of the
189
218
  [Apache 2.0 Licence](https://github.com/lovell/sharp/blob/master/LICENSE).
190
219
 
@@ -198,6 +227,7 @@ Use of libraries under the terms of the LGPLv3 is via the
198
227
  | Library | Used under the terms of |
199
228
  |---------------|----------------------------------------------------------------------------------------------------------|
200
229
  | cairo | Mozilla Public License 2.0 |
230
+ | expat | MIT Licence |
201
231
  | fontconfig | [fontconfig Licence](https://cgit.freedesktop.org/fontconfig/tree/COPYING) (BSD-like) |
202
232
  | freetype | [freetype Licence](http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
203
233
  | giflib | MIT Licence |
package/lib/channel.js CHANGED
@@ -27,7 +27,7 @@ const bool = {
27
27
  * @returns {Sharp}
28
28
  * @throws {Error} Invalid channel
29
29
  */
30
- const extractChannel = function extractChannel (channel) {
30
+ function extractChannel (channel) {
31
31
  if (channel === 'red') {
32
32
  channel = 0;
33
33
  } else if (channel === 'green') {
@@ -41,7 +41,7 @@ const extractChannel = function extractChannel (channel) {
41
41
  throw new Error('Cannot extract invalid channel ' + channel);
42
42
  }
43
43
  return this;
44
- };
44
+ }
45
45
 
46
46
  /**
47
47
  * Join one or more channels to the image.
@@ -59,7 +59,7 @@ const extractChannel = function extractChannel (channel) {
59
59
  * @returns {Sharp}
60
60
  * @throws {Error} Invalid parameters
61
61
  */
62
- const joinChannel = function joinChannel (images, options) {
62
+ function joinChannel (images, options) {
63
63
  if (Array.isArray(images)) {
64
64
  images.forEach(function (image) {
65
65
  this.options.joinChannelIn.push(this._createInputDescriptor(image, options));
@@ -68,7 +68,7 @@ const joinChannel = function joinChannel (images, options) {
68
68
  this.options.joinChannelIn.push(this._createInputDescriptor(images, options));
69
69
  }
70
70
  return this;
71
- };
71
+ }
72
72
 
73
73
  /**
74
74
  * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.
@@ -86,14 +86,14 @@ const joinChannel = function joinChannel (images, options) {
86
86
  * @returns {Sharp}
87
87
  * @throws {Error} Invalid parameters
88
88
  */
89
- const bandbool = function bandbool (boolOp) {
89
+ function bandbool (boolOp) {
90
90
  if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {
91
91
  this.options.bandBoolOp = boolOp;
92
92
  } else {
93
93
  throw new Error('Invalid bandbool operation ' + boolOp);
94
94
  }
95
95
  return this;
96
- };
96
+ }
97
97
 
98
98
  /**
99
99
  * Decorate the Sharp prototype with channel-related functions.
package/lib/colour.js CHANGED
@@ -27,7 +27,7 @@ const colourspace = {
27
27
  * @returns {Sharp}
28
28
  * @throws {Error} Invalid parameter
29
29
  */
30
- const background = function background (rgba) {
30
+ function background (rgba) {
31
31
  const colour = color(rgba);
32
32
  this.options.background = [
33
33
  colour.red(),
@@ -36,7 +36,7 @@ const background = function background (rgba) {
36
36
  Math.round(colour.alpha() * 255)
37
37
  ];
38
38
  return this;
39
- };
39
+ }
40
40
 
41
41
  /**
42
42
  * Convert to 8-bit greyscale; 256 shades of grey.
@@ -48,19 +48,19 @@ const background = function background (rgba) {
48
48
  * @param {Boolean} [greyscale=true]
49
49
  * @returns {Sharp}
50
50
  */
51
- const greyscale = function greyscale (greyscale) {
51
+ function greyscale (greyscale) {
52
52
  this.options.greyscale = is.bool(greyscale) ? greyscale : true;
53
53
  return this;
54
- };
54
+ }
55
55
 
56
56
  /**
57
57
  * Alternative spelling of `greyscale`.
58
58
  * @param {Boolean} [grayscale=true]
59
59
  * @returns {Sharp}
60
60
  */
61
- const grayscale = function grayscale (grayscale) {
61
+ function grayscale (grayscale) {
62
62
  return this.greyscale(grayscale);
63
- };
63
+ }
64
64
 
65
65
  /**
66
66
  * Set the output colourspace.
@@ -69,13 +69,13 @@ const grayscale = function grayscale (grayscale) {
69
69
  * @returns {Sharp}
70
70
  * @throws {Error} Invalid parameters
71
71
  */
72
- const toColourspace = function toColourspace (colourspace) {
72
+ function toColourspace (colourspace) {
73
73
  if (!is.string(colourspace)) {
74
74
  throw new Error('Invalid output colourspace ' + colourspace);
75
75
  }
76
76
  this.options.colourspace = colourspace;
77
77
  return this;
78
- };
78
+ }
79
79
 
80
80
  /**
81
81
  * Alternative spelling of `toColourspace`.
@@ -83,9 +83,9 @@ const toColourspace = function toColourspace (colourspace) {
83
83
  * @returns {Sharp}
84
84
  * @throws {Error} Invalid parameters
85
85
  */
86
- const toColorspace = function toColorspace (colorspace) {
86
+ function toColorspace (colorspace) {
87
87
  return this.toColourspace(colorspace);
88
- };
88
+ }
89
89
 
90
90
  /**
91
91
  * Decorate the Sharp prototype with colour-related functions.
package/lib/composite.js CHANGED
@@ -8,6 +8,8 @@ const is = require('./is');
8
8
  * The overlay image must be the same size or smaller than the processed image.
9
9
  * If both `top` and `left` options are provided, they take precedence over `gravity`.
10
10
  *
11
+ * If the overlay image contains an alpha channel then composition with premultiplication will occur.
12
+ *
11
13
  * @example
12
14
  * sharp('input.png')
13
15
  * .rotate(180)
@@ -33,14 +35,20 @@ const is = require('./is');
33
35
  * @param {Number} [options.left] - the pixel offset from the left edge.
34
36
  * @param {Boolean} [options.tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.
35
37
  * @param {Boolean} [options.cutout=false] - set to true to apply only the alpha channel of the overlay image to the input image, giving the appearance of one image being cut out of another.
38
+ * @param {Number} [options.density=72] - integral number representing the DPI for vector overlay image.
36
39
  * @param {Object} [options.raw] - describes overlay when using raw pixel data.
37
40
  * @param {Number} [options.raw.width]
38
41
  * @param {Number} [options.raw.height]
39
42
  * @param {Number} [options.raw.channels]
43
+ * @param {Object} [options.create] - describes a blank overlay to be created.
44
+ * @param {Number} [options.create.width]
45
+ * @param {Number} [options.create.height]
46
+ * @param {Number} [options.create.channels] - 3-4
47
+ * @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.
40
48
  * @returns {Sharp}
41
49
  * @throws {Error} Invalid parameters
42
50
  */
43
- const overlayWith = function overlayWith (overlay, options) {
51
+ function overlayWith (overlay, options) {
44
52
  this.options.overlay = this._createInputDescriptor(overlay, options, {
45
53
  allowStream: false
46
54
  });
@@ -60,10 +68,7 @@ const overlayWith = function overlayWith (overlay, options) {
60
68
  }
61
69
  }
62
70
  if (is.defined(options.left) || is.defined(options.top)) {
63
- if (
64
- is.integer(options.left) && is.inRange(options.left, 0, this.constructor.maximum.width) &&
65
- is.integer(options.top) && is.inRange(options.top, 0, this.constructor.maximum.height)
66
- ) {
71
+ if (is.integer(options.left) && options.left >= 0 && is.integer(options.top) && options.top >= 0) {
67
72
  this.options.overlayXOffset = options.left;
68
73
  this.options.overlayYOffset = options.top;
69
74
  } else {
@@ -81,7 +86,7 @@ const overlayWith = function overlayWith (overlay, options) {
81
86
  }
82
87
  }
83
88
  return this;
84
- };
89
+ }
85
90
 
86
91
  /**
87
92
  * Decorate the Sharp prototype with composite-related functions.
@@ -5,6 +5,7 @@ const util = require('util');
5
5
  const stream = require('stream');
6
6
  const events = require('events');
7
7
  const semver = require('semver');
8
+ const is = require('./is');
8
9
  const sharp = require('../build/Release/sharp.node');
9
10
 
10
11
  // Versioning
@@ -24,12 +25,15 @@ let versions = {
24
25
  } catch (err) {}
25
26
  })();
26
27
 
28
+ // Use NODE_DEBUG=sharp to enable libvips warnings
29
+ const debuglog = util.debuglog('sharp');
30
+
27
31
  /**
28
32
  * @class Sharp
29
33
  *
30
34
  * Constructor factory to create an instance of `sharp`, to which further methods are chained.
31
35
  *
32
- * JPEG, PNG or WebP format image data can be streamed out from this object.
36
+ * JPEG, PNG, WebP or TIFF format image data can be streamed out from this object.
33
37
  * When using Stream based output, derived attributes are available from the `info` event.
34
38
  *
35
39
  * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.
@@ -54,20 +58,42 @@ let versions = {
54
58
  * });
55
59
  * readableStream.pipe(transformer).pipe(writableStream);
56
60
  *
61
+ * @example
62
+ * // Create a blank 300x200 PNG image of semi-transluent red pixels
63
+ * sharp({
64
+ * create: {
65
+ * width: 300,
66
+ * height: 200,
67
+ * channels: 4,
68
+ * background: { r: 255, g: 0, b: 0, alpha: 128 }
69
+ * }
70
+ * })
71
+ * .png()
72
+ * .toBuffer()
73
+ * .then( ... );
74
+ *
57
75
  * @param {(Buffer|String)} [input] - if present, can be
58
76
  * a Buffer containing JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data, or
59
77
  * a String containing the path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
60
- * JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when null or undefined.
78
+ * JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
61
79
  * @param {Object} [options] - if present, is an Object with optional attributes.
62
80
  * @param {Number} [options.density=72] - integral number representing the DPI for vector images.
63
- * @param {Object} [options.raw] - describes raw pixel image data. See `raw()` for pixel ordering.
81
+ * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
64
82
  * @param {Number} [options.raw.width]
65
83
  * @param {Number} [options.raw.height]
66
- * @param {Number} [options.raw.channels]
84
+ * @param {Number} [options.raw.channels] - 1-4
85
+ * @param {Object} [options.create] - describes a new image to be created.
86
+ * @param {Number} [options.create.width]
87
+ * @param {Number} [options.create.height]
88
+ * @param {Number} [options.create.channels] - 3-4
89
+ * @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.
67
90
  * @returns {Sharp}
68
91
  * @throws {Error} Invalid parameters
69
92
  */
70
93
  const Sharp = function (input, options) {
94
+ if (arguments.length === 1 && !is.defined(input)) {
95
+ throw new Error('Invalid input');
96
+ }
71
97
  if (!(this instanceof Sharp)) {
72
98
  return new Sharp(input, options);
73
99
  }
@@ -75,7 +101,7 @@ const Sharp = function (input, options) {
75
101
  this.options = {
76
102
  // input options
77
103
  sequentialRead: false,
78
- limitInputPixels: maximum.pixels,
104
+ limitInputPixels: Math.pow(0x3FFF, 2),
79
105
  // ICC profiles
80
106
  iccProfilePath: path.join(__dirname, 'icc') + path.sep,
81
107
  // resize options
@@ -91,6 +117,7 @@ const Sharp = function (input, options) {
91
117
  height: -1,
92
118
  canvas: 'crop',
93
119
  crop: 0,
120
+ useExifOrientation: false,
94
121
  angle: 0,
95
122
  rotateBeforePreExtract: false,
96
123
  flip: false,
@@ -134,6 +161,7 @@ const Sharp = function (input, options) {
134
161
  streamOut: false,
135
162
  withMetadata: false,
136
163
  withMetadataOrientation: -1,
164
+ resolveWithObject: false,
137
165
  // output format
138
166
  jpegQuality: 80,
139
167
  jpegProgressive: false,
@@ -149,8 +177,15 @@ const Sharp = function (input, options) {
149
177
  webpLossless: false,
150
178
  webpNearLossless: false,
151
179
  tiffQuality: 80,
180
+ tiffCompression: 'jpeg',
181
+ tiffPredictor: 'none',
182
+ tiffSquash: false,
183
+ tiffXres: 1.0,
184
+ tiffYres: 1.0,
152
185
  tileSize: 256,
153
186
  tileOverlap: 0,
187
+ // Function to notify of libvips warnings
188
+ debuglog: debuglog,
154
189
  // Function to notify of queue length changes
155
190
  queueListener: function (queueLength) {
156
191
  queue.emit('change', queueLength);
@@ -161,18 +196,6 @@ const Sharp = function (input, options) {
161
196
  };
162
197
  util.inherits(Sharp, stream.Duplex);
163
198
 
164
- /**
165
- * Pixel limits.
166
- * @member
167
- * @private
168
- */
169
- const maximum = {
170
- width: 0x3FFF,
171
- height: 0x3FFF,
172
- pixels: Math.pow(0x3FFF, 2)
173
- };
174
- Sharp.maximum = maximum;
175
-
176
199
  /**
177
200
  * An EventEmitter that emits a `change` event when a task is either:
178
201
  * - queued, waiting for _libuv_ to provide a worker thread
@@ -189,7 +212,7 @@ Sharp.queue = queue;
189
212
  /**
190
213
  * An Object containing nested boolean values representing the available input and output formats/methods.
191
214
  * @example
192
- * console.log(sharp.format());
215
+ * console.log(sharp.format);
193
216
  * @returns {Object}
194
217
  */
195
218
  Sharp.format = sharp.format();