mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add support for prebuilt sharp binaries on common platforms
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [extractChannel](#extractchannel)
|
||||
- [joinChannel](#joinchannel)
|
||||
- [bandbool](#bandbool)
|
||||
- [extractChannel][1]
|
||||
- [joinChannel][2]
|
||||
- [bandbool][3]
|
||||
|
||||
## extractChannel
|
||||
|
||||
@@ -12,7 +12,7 @@ Extract a single channel from a multi-channel image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `channel` **([Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively.
|
||||
- `channel` **([Number][4] \| [String][5])** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively.
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -25,7 +25,7 @@ sharp(input)
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid channel
|
||||
- Throws **[Error][6]** Invalid channel
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -44,11 +44,11 @@ For raw pixel input, the `options` object should contain a `raw` attribute, whic
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `images` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Buffer](https://nodejs.org/api/buffer.html))> | [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Buffer](https://nodejs.org/api/buffer.html))** one or more images (file paths, Buffers).
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** image options, see `sharp()` constructor.
|
||||
- `images` **([Array][7]<([String][5] \| [Buffer][8])> | [String][5] \| [Buffer][8])** one or more images (file paths, Buffers).
|
||||
- `options` **[Object][9]** image options, see `sharp()` constructor.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][6]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -58,7 +58,7 @@ Perform a bitwise boolean operation on all input image channels (bands) to produ
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `boolOp` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
|
||||
- `boolOp` **[String][5]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -72,6 +72,24 @@ sharp('3-channel-rgb-input.png')
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][6]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #extractchannel
|
||||
|
||||
[2]: #joinchannel
|
||||
|
||||
[3]: #bandbool
|
||||
|
||||
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
||||
|
||||
[8]: https://nodejs.org/api/buffer.html
|
||||
|
||||
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [background](#background)
|
||||
- [greyscale](#greyscale)
|
||||
- [grayscale](#grayscale)
|
||||
- [toColourspace](#tocolourspace)
|
||||
- [toColorspace](#tocolorspace)
|
||||
- [background][1]
|
||||
- [greyscale][2]
|
||||
- [grayscale][3]
|
||||
- [toColourspace][4]
|
||||
- [toColorspace][5]
|
||||
|
||||
## background
|
||||
|
||||
@@ -19,10 +19,10 @@ The alpha value is a float between `0` (transparent) and `1` (opaque).
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `rgba` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
|
||||
- `rgba` **([String][6] \| [Object][7])** parsed by the [color][8] module to extract values for red, green, blue and alpha.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameter
|
||||
- Throws **[Error][9]** Invalid parameter
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -37,7 +37,7 @@ An alpha channel may be present, and will be unchanged by the operation.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `greyscale` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `greyscale` **[Boolean][10]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -47,7 +47,7 @@ Alternative spelling of `greyscale`.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `grayscale` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `grayscale` **[Boolean][10]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -58,10 +58,10 @@ By default output image will be web-friendly sRGB, with additional channels inte
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `colourspace` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568)
|
||||
- `colourspace` **[String][6]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][11]
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][9]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -71,9 +71,31 @@ Alternative spelling of `toColourspace`.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `colorspace` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** output colorspace.
|
||||
- `colorspace` **[String][6]?** output colorspace.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][9]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #background
|
||||
|
||||
[2]: #greyscale
|
||||
|
||||
[3]: #grayscale
|
||||
|
||||
[4]: #tocolourspace
|
||||
|
||||
[5]: #tocolorspace
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[8]: https://www.npmjs.org/package/color
|
||||
|
||||
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[11]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [overlayWith](#overlaywith)
|
||||
- [overlayWith][1]
|
||||
|
||||
## overlayWith
|
||||
|
||||
@@ -15,23 +15,23 @@ If the overlay image contains an alpha channel then composition with premultipli
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `overlay` **([Buffer](https://nodejs.org/api/buffer.html) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** Buffer containing image data or String containing the path to an image file.
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.gravity` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** gravity at which to place the overlay. (optional, default `'centre'`)
|
||||
- `options.top` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** the pixel offset from the top edge.
|
||||
- `options.left` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** the pixel offset from the left edge.
|
||||
- `options.tile` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`)
|
||||
- `options.cutout` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 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. (optional, default `false`)
|
||||
- `options.density` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** integral number representing the DPI for vector overlay image. (optional, default `72`)
|
||||
- `options.raw` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** describes overlay when using raw pixel data.
|
||||
- `options.raw.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.channels` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.create` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** describes a blank overlay to be created.
|
||||
- `options.create.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.create.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.create.channels` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** 3-4
|
||||
- `options.create.background` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))?** parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
|
||||
- `overlay` **([Buffer][2] \| [String][3])** Buffer containing image data or String containing the path to an image file.
|
||||
- `options` **[Object][4]?**
|
||||
- `options.gravity` **[String][3]** gravity at which to place the overlay. (optional, default `'centre'`)
|
||||
- `options.top` **[Number][5]?** the pixel offset from the top edge.
|
||||
- `options.left` **[Number][5]?** the pixel offset from the left edge.
|
||||
- `options.tile` **[Boolean][6]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`)
|
||||
- `options.cutout` **[Boolean][6]** 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. (optional, default `false`)
|
||||
- `options.density` **[Number][5]** integral number representing the DPI for vector overlay image. (optional, default `72`)
|
||||
- `options.raw` **[Object][4]?** describes overlay when using raw pixel data.
|
||||
- `options.raw.width` **[Number][5]?**
|
||||
- `options.raw.height` **[Number][5]?**
|
||||
- `options.raw.channels` **[Number][5]?**
|
||||
- `options.create` **[Object][4]?** describes a blank overlay to be created.
|
||||
- `options.create.width` **[Number][5]?**
|
||||
- `options.create.height` **[Number][5]?**
|
||||
- `options.create.channels` **[Number][5]?** 3-4
|
||||
- `options.create.background` **([String][3] \| [Object][4])?** parsed by the [color][7] module to extract values for red, green, blue and alpha.
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -54,6 +54,22 @@ sharp('input.png')
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][8]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #overlaywith
|
||||
|
||||
[2]: https://nodejs.org/api/buffer.html
|
||||
|
||||
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[7]: https://www.npmjs.org/package/color
|
||||
|
||||
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
@@ -2,33 +2,33 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [Sharp](#sharp)
|
||||
- [format](#format)
|
||||
- [versions](#versions)
|
||||
- [queue](#queue)
|
||||
- [Sharp][1]
|
||||
- [format][2]
|
||||
- [versions][3]
|
||||
- [queue][4]
|
||||
|
||||
## Sharp
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `input` **([Buffer](https://nodejs.org/api/buffer.html) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))?** if present, can be
|
||||
- `input` **([Buffer][5] \| [String][6])?** if present, can be
|
||||
a Buffer containing JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data, or
|
||||
a String containing the path to an JPEG, PNG, WebP, GIF, SVG or TIFF image file.
|
||||
JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** if present, is an Object with optional attributes.
|
||||
- `options.failOnError` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** by default apply a "best effort"
|
||||
- `options` **[Object][7]?** if present, is an Object with optional attributes.
|
||||
- `options.failOnError` **[Boolean][8]** by default apply a "best effort"
|
||||
to decode images, even if the data is corrupt or invalid. Set this flag to true
|
||||
if you'd rather halt processing and raise an error when loading invalid images. (optional, default `false`)
|
||||
- `options.density` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** integral number representing the DPI for vector images. (optional, default `72`)
|
||||
- `options.raw` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** describes raw pixel input image data. See `raw()` for pixel ordering.
|
||||
- `options.raw.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.channels` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** 1-4
|
||||
- `options.create` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** describes a new image to be created.
|
||||
- `options.create.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.create.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.create.channels` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** 3-4
|
||||
- `options.create.background` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))?** parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
|
||||
- `options.density` **[Number][9]** integral number representing the DPI for vector images. (optional, default `72`)
|
||||
- `options.raw` **[Object][7]?** describes raw pixel input image data. See `raw()` for pixel ordering.
|
||||
- `options.raw.width` **[Number][9]?**
|
||||
- `options.raw.height` **[Number][9]?**
|
||||
- `options.raw.channels` **[Number][9]?** 1-4
|
||||
- `options.create` **[Object][7]?** describes a new image to be created.
|
||||
- `options.create.width` **[Number][9]?**
|
||||
- `options.create.height` **[Number][9]?**
|
||||
- `options.create.channels` **[Number][9]?** 3-4
|
||||
- `options.create.background` **([String][6] \| [Object][7])?** parsed by the [color][10] module to extract values for red, green, blue and alpha.
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -69,9 +69,9 @@ sharp({
|
||||
.then( ... );
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][11]** Invalid parameters
|
||||
|
||||
Returns **[Sharp](#sharp)**
|
||||
Returns **[Sharp][12]**
|
||||
|
||||
### format
|
||||
|
||||
@@ -83,7 +83,7 @@ An Object containing nested boolean values representing the available input and
|
||||
console.log(sharp.format);
|
||||
```
|
||||
|
||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||
Returns **[Object][7]**
|
||||
|
||||
### versions
|
||||
|
||||
@@ -109,3 +109,27 @@ sharp.queue.on('change', function(queueLength) {
|
||||
console.log('Queue contains ' + queueLength + ' task(s)');
|
||||
});
|
||||
```
|
||||
|
||||
[1]: #sharp
|
||||
|
||||
[2]: #format
|
||||
|
||||
[3]: #versions
|
||||
|
||||
[4]: #queue
|
||||
|
||||
[5]: https://nodejs.org/api/buffer.html
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[10]: https://www.npmjs.org/package/color
|
||||
|
||||
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[12]: #sharp
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [clone](#clone)
|
||||
- [metadata](#metadata)
|
||||
- [stats](#stats)
|
||||
- [limitInputPixels](#limitinputpixels)
|
||||
- [sequentialRead](#sequentialread)
|
||||
- [clone][1]
|
||||
- [metadata][2]
|
||||
- [stats][3]
|
||||
- [limitInputPixels][4]
|
||||
- [sequentialRead][5]
|
||||
|
||||
## clone
|
||||
|
||||
@@ -33,23 +33,23 @@ Fast access to (uncached) image metadata without decoding any compressed image d
|
||||
A Promises/A+ promise is returned when `callback` is not provided.
|
||||
|
||||
- `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`
|
||||
- `width`: Number of pixels wide
|
||||
- `height`: Number of pixels high
|
||||
- `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L636)
|
||||
- `width`: Number of pixels wide (EXIF orientation is not taken into consideration)
|
||||
- `height`: Number of pixels high (EXIF orientation is not taken into consideration)
|
||||
- `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][6]
|
||||
- `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
||||
- `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L672)
|
||||
- `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...][7]
|
||||
- `density`: Number of pixels per inch (DPI), if present
|
||||
- `hasProfile`: Boolean indicating the presence of an embedded ICC profile
|
||||
- `hasAlpha`: Boolean indicating the presence of an alpha transparency channel
|
||||
- `orientation`: Number value of the EXIF Orientation header, if present
|
||||
- `exif`: Buffer containing raw EXIF data, if present
|
||||
- `icc`: Buffer containing raw [ICC](https://www.npmjs.com/package/icc) profile data, if present
|
||||
- `icc`: Buffer containing raw [ICC][8] profile data, if present
|
||||
- `iptc`: Buffer containing raw IPTC data, if present
|
||||
- `xmp`: Buffer containing raw XMP data, if present
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** called with the arguments `(err, metadata)`
|
||||
- `callback` **[Function][9]?** called with the arguments `(err, metadata)`
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -68,7 +68,7 @@ image
|
||||
});
|
||||
```
|
||||
|
||||
Returns **([Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)> | Sharp)**
|
||||
Returns **([Promise][10]<[Object][11]> | Sharp)**
|
||||
|
||||
## stats
|
||||
|
||||
@@ -90,7 +90,7 @@ A Promise is returned when `callback` is not provided.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** called with the arguments `(err, stats)`
|
||||
- `callback` **[Function][9]?** called with the arguments `(err, stats)`
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -103,7 +103,7 @@ image
|
||||
});
|
||||
```
|
||||
|
||||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>**
|
||||
Returns **[Promise][10]<[Object][11]>**
|
||||
|
||||
## limitInputPixels
|
||||
|
||||
@@ -113,10 +113,10 @@ The default limit is 268402689 (0x3FFF _ 0x3FFF) pixels.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `limit` **([Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** an integral Number of pixels, zero or false to remove limit, true to use default limit.
|
||||
- `limit` **([Number][12] \| [Boolean][13])** an integral Number of pixels, zero or false to remove limit, true to use default limit.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid limit
|
||||
- Throws **[Error][14]** Invalid limit
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -129,6 +129,34 @@ The default behaviour _before_ function call is `false`, meaning the libvips acc
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `sequentialRead` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `sequentialRead` **[Boolean][13]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #clone
|
||||
|
||||
[2]: #metadata
|
||||
|
||||
[3]: #stats
|
||||
|
||||
[4]: #limitinputpixels
|
||||
|
||||
[5]: #sequentialread
|
||||
|
||||
[6]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L636
|
||||
|
||||
[7]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L672
|
||||
|
||||
[8]: https://www.npmjs.com/package/icc
|
||||
|
||||
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
||||
|
||||
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||
|
||||
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [rotate](#rotate)
|
||||
- [extract](#extract)
|
||||
- [flip](#flip)
|
||||
- [flop](#flop)
|
||||
- [sharpen](#sharpen)
|
||||
- [blur](#blur)
|
||||
- [extend](#extend)
|
||||
- [flatten](#flatten)
|
||||
- [trim](#trim)
|
||||
- [gamma](#gamma)
|
||||
- [negate](#negate)
|
||||
- [normalise](#normalise)
|
||||
- [normalize](#normalize)
|
||||
- [convolve](#convolve)
|
||||
- [threshold](#threshold)
|
||||
- [boolean](#boolean)
|
||||
- [linear](#linear)
|
||||
- [rotate][1]
|
||||
- [extract][2]
|
||||
- [flip][3]
|
||||
- [flop][4]
|
||||
- [sharpen][5]
|
||||
- [blur][6]
|
||||
- [extend][7]
|
||||
- [flatten][8]
|
||||
- [trim][9]
|
||||
- [gamma][10]
|
||||
- [negate][11]
|
||||
- [normalise][12]
|
||||
- [normalize][13]
|
||||
- [convolve][14]
|
||||
- [threshold][15]
|
||||
- [boolean][16]
|
||||
- [linear][17]
|
||||
|
||||
## rotate
|
||||
|
||||
@@ -38,7 +38,7 @@ for example `rotate(x).extract(y)` will produce a different result to `extract(y
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `angle` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** angle of rotation, must be a multiple of 90. (optional, default `auto`)
|
||||
- `angle` **[Number][18]** angle of rotation, must be a multiple of 90. (optional, default `auto`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -54,7 +54,7 @@ const pipeline = sharp()
|
||||
readableStream.pipe(pipeline);
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -68,11 +68,11 @@ Extract a region of the image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||
- `options.left` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** zero-indexed offset from left edge
|
||||
- `options.top` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** zero-indexed offset from top edge
|
||||
- `options.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** dimension of extracted image
|
||||
- `options.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** dimension of extracted image
|
||||
- `options` **[Object][20]**
|
||||
- `options.left` **[Number][18]** zero-indexed offset from left edge
|
||||
- `options.top` **[Number][18]** zero-indexed offset from top edge
|
||||
- `options.width` **[Number][18]** dimension of extracted image
|
||||
- `options.height` **[Number][18]** dimension of extracted image
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -94,7 +94,7 @@ sharp(input)
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -105,7 +105,7 @@ The use of `flip` implies the removal of the EXIF `Orientation` tag, if any.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `flip` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `flip` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -116,7 +116,7 @@ The use of `flop` implies the removal of the EXIF `Orientation` tag, if any.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `flop` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `flop` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -129,12 +129,12 @@ Separate control over the level of sharpening in "flat" and "jagged" areas is av
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `sigma` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.
|
||||
- `flat` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the level of sharpening to apply to "flat" areas. (optional, default `1.0`)
|
||||
- `jagged` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the level of sharpening to apply to "jagged" areas. (optional, default `2.0`)
|
||||
- `sigma` **[Number][18]?** the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.
|
||||
- `flat` **[Number][18]** the level of sharpening to apply to "flat" areas. (optional, default `1.0`)
|
||||
- `jagged` **[Number][18]** the level of sharpening to apply to "jagged" areas. (optional, default `2.0`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -146,10 +146,10 @@ When a `sigma` is provided, performs a slower, more accurate Gaussian blur.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `sigma` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.
|
||||
- `sigma` **[Number][18]?** a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -160,11 +160,11 @@ This operation will always occur after resizing and extraction, if any.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `extend` **([Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** single pixel count to add to all edges or an Object with per-edge counts
|
||||
- `extend.top` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `extend.left` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `extend.bottom` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `extend.right` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `extend` **([Number][18] \| [Object][20])** single pixel count to add to all edges or an Object with per-edge counts
|
||||
- `extend.top` **[Number][18]?**
|
||||
- `extend.left` **[Number][18]?**
|
||||
- `extend.bottom` **[Number][18]?**
|
||||
- `extend.right` **[Number][18]?**
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -178,7 +178,7 @@ sharp(input)
|
||||
...
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -188,7 +188,7 @@ Merge alpha transparency channel, if any, with `background`.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `flatten` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `flatten` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -198,10 +198,10 @@ Trim "boring" pixels from all edges that contain values within a percentage simi
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `tolerance` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** value between 1 and 99 representing the percentage similarity. (optional, default `10`)
|
||||
- `tolerance` **[Number][18]** value between 1 and 99 representing the percentage similarity. (optional, default `10`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -215,10 +215,10 @@ when applying a gamma correction.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `gamma` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** value between 1.0 and 3.0. (optional, default `2.2`)
|
||||
- `gamma` **[Number][18]** value between 1.0 and 3.0. (optional, default `2.2`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -228,7 +228,7 @@ Produce the "negative" of the image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `negate` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `negate` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -238,7 +238,7 @@ Enhance output image contrast by stretching its luminance to cover the full dyna
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `normalise` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `normalise` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -248,7 +248,7 @@ Alternative spelling of normalise.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `normalize` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `normalize` **[Boolean][21]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -258,12 +258,12 @@ Convolve the image with the specified kernel.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `kernel` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||
- `kernel.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** width of the kernel in pixels.
|
||||
- `kernel.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** width of the kernel in pixels.
|
||||
- `kernel.kernel` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** Array of length `width*height` containing the kernel values.
|
||||
- `kernel.scale` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the scale of the kernel in pixels. (optional, default `sum`)
|
||||
- `kernel.offset` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the offset of the kernel in pixels. (optional, default `0`)
|
||||
- `kernel` **[Object][20]**
|
||||
- `kernel.width` **[Number][18]** width of the kernel in pixels.
|
||||
- `kernel.height` **[Number][18]** width of the kernel in pixels.
|
||||
- `kernel.kernel` **[Array][22]<[Number][18]>** Array of length `width*height` containing the kernel values.
|
||||
- `kernel.scale` **[Number][18]** the scale of the kernel in pixels. (optional, default `sum`)
|
||||
- `kernel.offset` **[Number][18]** the offset of the kernel in pixels. (optional, default `0`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -281,7 +281,7 @@ sharp(input)
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -291,13 +291,13 @@ Any pixel value greather than or equal to the threshold value will be set to 255
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `threshold` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default `128`)
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.greyscale` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** convert to single channel greyscale. (optional, default `true`)
|
||||
- `options.grayscale` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** alternative spelling for greyscale. (optional, default `true`)
|
||||
- `threshold` **[Number][18]** a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default `128`)
|
||||
- `options` **[Object][20]?**
|
||||
- `options.greyscale` **[Boolean][21]** convert to single channel greyscale. (optional, default `true`)
|
||||
- `options.grayscale` **[Boolean][21]** alternative spelling for greyscale. (optional, default `true`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -310,16 +310,16 @@ the selected bitwise boolean `operation` between the corresponding pixels of the
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `operand` **([Buffer](https://nodejs.org/api/buffer.html) \| [String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))** Buffer containing image data or String containing the path to an image file.
|
||||
- `operator` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.raw` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** describes operand when using raw pixel data.
|
||||
- `options.raw.width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `options.raw.channels` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `operand` **([Buffer][23] \| [String][24])** Buffer containing image data or String containing the path to an image file.
|
||||
- `operator` **[String][24]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
|
||||
- `options` **[Object][20]?**
|
||||
- `options.raw` **[Object][20]?** describes operand when using raw pixel data.
|
||||
- `options.raw.width` **[Number][18]?**
|
||||
- `options.raw.height` **[Number][18]?**
|
||||
- `options.raw.channels` **[Number][18]?**
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -329,10 +329,58 @@ Apply the linear formula a \* input + b to the image (levels adjustment)
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `a` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** multiplier (optional, default `1.0`)
|
||||
- `b` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** offset (optional, default `0.0`)
|
||||
- `a` **[Number][18]** multiplier (optional, default `1.0`)
|
||||
- `b` **[Number][18]** offset (optional, default `0.0`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][19]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #rotate
|
||||
|
||||
[2]: #extract
|
||||
|
||||
[3]: #flip
|
||||
|
||||
[4]: #flop
|
||||
|
||||
[5]: #sharpen
|
||||
|
||||
[6]: #blur
|
||||
|
||||
[7]: #extend
|
||||
|
||||
[8]: #flatten
|
||||
|
||||
[9]: #trim
|
||||
|
||||
[10]: #gamma
|
||||
|
||||
[11]: #negate
|
||||
|
||||
[12]: #normalise
|
||||
|
||||
[13]: #normalize
|
||||
|
||||
[14]: #convolve
|
||||
|
||||
[15]: #threshold
|
||||
|
||||
[16]: #boolean
|
||||
|
||||
[17]: #linear
|
||||
|
||||
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
||||
|
||||
[23]: https://nodejs.org/api/buffer.html
|
||||
|
||||
[24]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [toFile](#tofile)
|
||||
- [toBuffer](#tobuffer)
|
||||
- [withMetadata](#withmetadata)
|
||||
- [jpeg](#jpeg)
|
||||
- [png](#png)
|
||||
- [webp](#webp)
|
||||
- [tiff](#tiff)
|
||||
- [raw](#raw)
|
||||
- [toFormat](#toformat)
|
||||
- [tile](#tile)
|
||||
- [toFile][1]
|
||||
- [toBuffer][2]
|
||||
- [withMetadata][3]
|
||||
- [jpeg][4]
|
||||
- [png][5]
|
||||
- [webp][6]
|
||||
- [tiff][7]
|
||||
- [raw][8]
|
||||
- [toFormat][9]
|
||||
- [tile][10]
|
||||
|
||||
## toFile
|
||||
|
||||
@@ -25,16 +25,16 @@ A `Promise` is returned when `callback` is not provided.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `fileOut` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the path to write the image data to.
|
||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** called on completion with two arguments `(err, info)`.
|
||||
- `fileOut` **[String][11]** the path to write the image data to.
|
||||
- `callback` **[Function][12]?** called on completion with two arguments `(err, info)`.
|
||||
`info` contains the output image `format`, `size` (bytes), `width`, `height`,
|
||||
`channels` and `premultiplied` (indicating if premultiplication was used).
|
||||
When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][13]** Invalid parameters
|
||||
|
||||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** when no callback is provided
|
||||
Returns **[Promise][14]<[Object][15]>** when no callback is provided
|
||||
|
||||
## toBuffer
|
||||
|
||||
@@ -54,11 +54,11 @@ A `Promise` is returned when `callback` is not provided.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.resolveWithObject` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.
|
||||
- `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?**
|
||||
- `options` **[Object][15]?**
|
||||
- `options.resolveWithObject` **[Boolean][16]?** Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.
|
||||
- `callback` **[Function][12]?**
|
||||
|
||||
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>** when no callback is provided
|
||||
Returns **[Promise][14]<[Buffer][17]>** when no callback is provided
|
||||
|
||||
## withMetadata
|
||||
|
||||
@@ -68,11 +68,11 @@ This will also convert to and add a web-friendly sRGB ICC profile.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `withMetadata` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `withMetadata.orientation` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** value between 1 and 8, used to update the EXIF `Orientation` tag.
|
||||
- `withMetadata` **[Object][15]?**
|
||||
- `withMetadata.orientation` **[Number][18]?** value between 1 and 8, used to update the EXIF `Orientation` tag.
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][13]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -82,18 +82,18 @@ Use these JPEG options for output image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** output options
|
||||
- `options.quality` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.progressive` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use progressive (interlace) scan (optional, default `false`)
|
||||
- `options.chromaSubsampling` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`)
|
||||
- `options.trellisQuantisation` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** apply trellis quantisation, requires mozjpeg (optional, default `false`)
|
||||
- `options.overshootDeringing` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** apply overshoot deringing, requires mozjpeg (optional, default `false`)
|
||||
- `options.optimiseScans` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`)
|
||||
- `options.optimizeScans` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** alternative spelling of optimiseScans (optional, default `false`)
|
||||
- `options.force` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** force JPEG output, otherwise attempt to use input format (optional, default `true`)
|
||||
- `options` **[Object][15]?** output options
|
||||
- `options.quality` **[Number][18]** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.progressive` **[Boolean][16]** use progressive (interlace) scan (optional, default `false`)
|
||||
- `options.chromaSubsampling` **[String][11]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`)
|
||||
- `options.trellisQuantisation` **[Boolean][16]** apply trellis quantisation, requires mozjpeg (optional, default `false`)
|
||||
- `options.overshootDeringing` **[Boolean][16]** apply overshoot deringing, requires mozjpeg (optional, default `false`)
|
||||
- `options.optimiseScans` **[Boolean][16]** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`)
|
||||
- `options.optimizeScans` **[Boolean][16]** alternative spelling of optimiseScans (optional, default `false`)
|
||||
- `options.force` **[Boolean][16]** force JPEG output, otherwise attempt to use input format (optional, default `true`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options
|
||||
- Throws **[Error][13]** Invalid options
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -103,14 +103,14 @@ Use these PNG options for output image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.progressive` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use progressive (interlace) scan (optional, default `false`)
|
||||
- `options.compressionLevel` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** zlib compression level, 0-9 (optional, default `9`)
|
||||
- `options.adaptiveFiltering` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use adaptive row filtering (optional, default `false`)
|
||||
- `options.force` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** force PNG output, otherwise attempt to use input format (optional, default `true`)
|
||||
- `options` **[Object][15]?**
|
||||
- `options.progressive` **[Boolean][16]** use progressive (interlace) scan (optional, default `false`)
|
||||
- `options.compressionLevel` **[Number][18]** zlib compression level, 0-9 (optional, default `9`)
|
||||
- `options.adaptiveFiltering` **[Boolean][16]** use adaptive row filtering (optional, default `false`)
|
||||
- `options.force` **[Boolean][16]** force PNG output, otherwise attempt to use input format (optional, default `true`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options
|
||||
- Throws **[Error][13]** Invalid options
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -120,15 +120,15 @@ Use these WebP options for output image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** output options
|
||||
- `options.quality` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.alphaQuality` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** quality of alpha layer, integer 0-100 (optional, default `100`)
|
||||
- `options.lossless` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use lossless compression mode (optional, default `false`)
|
||||
- `options.nearLossless` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use near_lossless compression mode (optional, default `false`)
|
||||
- `options.force` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** force WebP output, otherwise attempt to use input format (optional, default `true`)
|
||||
- `options` **[Object][15]?** output options
|
||||
- `options.quality` **[Number][18]** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.alphaQuality` **[Number][18]** quality of alpha layer, integer 0-100 (optional, default `100`)
|
||||
- `options.lossless` **[Boolean][16]** use lossless compression mode (optional, default `false`)
|
||||
- `options.nearLossless` **[Boolean][16]** use near_lossless compression mode (optional, default `false`)
|
||||
- `options.force` **[Boolean][16]** force WebP output, otherwise attempt to use input format (optional, default `true`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options
|
||||
- Throws **[Error][13]** Invalid options
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -138,17 +138,17 @@ Use these TIFF options for output image.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** output options
|
||||
- `options.quality` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.force` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** force TIFF output, otherwise attempt to use input format (optional, default `true`)
|
||||
- `options.compression` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** compression options: lzw, deflate, jpeg (optional, default `'jpeg'`)
|
||||
- `options.predictor` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** compression predictor options: none, horizontal, float (optional, default `'horizontal'`)
|
||||
- `options.xres` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** horizontal resolution in pixels/mm (optional, default `1.0`)
|
||||
- `options.yres` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** vertical resolution in pixels/mm (optional, default `1.0`)
|
||||
- `options.squash` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** squash 8-bit images down to 1 bit (optional, default `false`)
|
||||
- `options` **[Object][15]?** output options
|
||||
- `options.quality` **[Number][18]** quality, integer 1-100 (optional, default `80`)
|
||||
- `options.force` **[Boolean][16]** force TIFF output, otherwise attempt to use input format (optional, default `true`)
|
||||
- `options.compression` **[Boolean][16]** compression options: lzw, deflate, jpeg (optional, default `'jpeg'`)
|
||||
- `options.predictor` **[Boolean][16]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`)
|
||||
- `options.xres` **[Number][18]** horizontal resolution in pixels/mm (optional, default `1.0`)
|
||||
- `options.yres` **[Number][18]** vertical resolution in pixels/mm (optional, default `1.0`)
|
||||
- `options.squash` **[Boolean][16]** squash 8-bit images down to 1 bit (optional, default `false`)
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid options
|
||||
- Throws **[Error][13]** Invalid options
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -164,11 +164,11 @@ Force output to a given format.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `format` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))** as a String or an Object with an 'id' attribute
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** output options
|
||||
- `format` **([String][11] \| [Object][15])** as a String or an Object with an 'id' attribute
|
||||
- `options` **[Object][15]** output options
|
||||
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** unsupported format or options
|
||||
- Throws **[Error][13]** unsupported format or options
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -180,12 +180,12 @@ Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed arc
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `tile` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `tile.size` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** tile size in pixels, a value between 1 and 8192. (optional, default `256`)
|
||||
- `tile.overlap` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** tile overlap in pixels, a value between 0 and 8192. (optional, default `0`)
|
||||
- `tile.angle` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** tile angle of rotation, must be a multiple of 90. (optional, default `0`)
|
||||
- `tile.container` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`)
|
||||
- `tile.layout` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** filesystem layout, possible values are `dz`, `zoomify` or `google`. (optional, default `'dz'`)
|
||||
- `tile` **[Object][15]?**
|
||||
- `tile.size` **[Number][18]** tile size in pixels, a value between 1 and 8192. (optional, default `256`)
|
||||
- `tile.overlap` **[Number][18]** tile overlap in pixels, a value between 0 and 8192. (optional, default `0`)
|
||||
- `tile.angle` **[Number][18]** tile angle of rotation, must be a multiple of 90. (optional, default `0`)
|
||||
- `tile.container` **[String][11]** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`)
|
||||
- `tile.layout` **[String][11]** filesystem layout, possible values are `dz`, `zoomify` or `google`. (optional, default `'dz'`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -201,6 +201,42 @@ sharp('input.tiff')
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][13]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #tofile
|
||||
|
||||
[2]: #tobuffer
|
||||
|
||||
[3]: #withmetadata
|
||||
|
||||
[4]: #jpeg
|
||||
|
||||
[5]: #png
|
||||
|
||||
[6]: #webp
|
||||
|
||||
[7]: #tiff
|
||||
|
||||
[8]: #raw
|
||||
|
||||
[9]: #toformat
|
||||
|
||||
[10]: #tile
|
||||
|
||||
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
||||
|
||||
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||
|
||||
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[17]: https://nodejs.org/api/buffer.html
|
||||
|
||||
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [resize](#resize)
|
||||
- [crop](#crop)
|
||||
- [embed](#embed)
|
||||
- [max](#max)
|
||||
- [min](#min)
|
||||
- [ignoreAspectRatio](#ignoreaspectratio)
|
||||
- [withoutEnlargement](#withoutenlargement)
|
||||
- [resize][1]
|
||||
- [crop][2]
|
||||
- [embed][3]
|
||||
- [max][4]
|
||||
- [min][5]
|
||||
- [ignoreAspectRatio][6]
|
||||
- [withoutEnlargement][7]
|
||||
|
||||
## resize
|
||||
|
||||
@@ -17,18 +17,18 @@ By default, the resized image is centre cropped to the exact size specified.
|
||||
|
||||
Possible kernels are:
|
||||
|
||||
- `nearest`: Use [nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation).
|
||||
- `cubic`: Use a [Catmull-Rom spline](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).
|
||||
- `lanczos2`: Use a [Lanczos kernel](https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel) with `a=2`.
|
||||
- `nearest`: Use [nearest neighbour interpolation][8].
|
||||
- `cubic`: Use a [Catmull-Rom spline][9].
|
||||
- `lanczos2`: Use a [Lanczos kernel][10] with `a=2`.
|
||||
- `lanczos3`: Use a Lanczos kernel with `a=3` (the default).
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `width` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
|
||||
- `height` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
||||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
|
||||
- `options.kernel` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the kernel to use for image reduction. (optional, default `'lanczos3'`)
|
||||
- `options.fastShrinkOnLoad` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moiré pattern on some images. (optional, default `true`)
|
||||
- `width` **[Number][11]?** pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
|
||||
- `height` **[Number][11]?** pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
||||
- `options` **[Object][12]?**
|
||||
- `options.kernel` **[String][13]** the kernel to use for image reduction. (optional, default `'lanczos3'`)
|
||||
- `options.fastShrinkOnLoad` **[Boolean][14]** take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moiré pattern on some images. (optional, default `true`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -47,7 +47,7 @@ sharp(inputBuffer)
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][15]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -61,12 +61,12 @@ Possible attributes of the optional `sharp.gravity` are `north`, `northeast`, `e
|
||||
The experimental strategy-based approach resizes so one dimension is at its target length
|
||||
then repeatedly ranks edge regions, discarding the edge with the lowest score based on the selected strategy.
|
||||
|
||||
- `entropy`: focus on the region with the highest [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29).
|
||||
- `entropy`: focus on the region with the highest [Shannon entropy][16].
|
||||
- `attention`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `crop` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A member of `sharp.gravity` to crop to an edge/corner or `sharp.strategy` to crop dynamically. (optional, default `'centre'`)
|
||||
- `crop` **[String][13]** A member of `sharp.gravity` to crop to an edge/corner or `sharp.strategy` to crop dynamically. (optional, default `'centre'`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -82,7 +82,7 @@ const transformer = sharp()
|
||||
readableStream.pipe(transformer).pipe(writableStream);
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][15]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -96,7 +96,7 @@ contain an alpha channel, even when the input image does not.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `embed` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A member of `sharp.gravity` to embed to an edge/corner. (optional, default `'centre'`)
|
||||
- `embed` **[String][13]** A member of `sharp.gravity` to embed to an edge/corner. (optional, default `'centre'`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -115,7 +115,7 @@ sharp('input.gif')
|
||||
});
|
||||
```
|
||||
|
||||
- Throws **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** Invalid parameters
|
||||
- Throws **[Error][15]** Invalid parameters
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
@@ -169,6 +169,38 @@ The default behaviour _before_ function call is `false`, meaning the image will
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `withoutEnlargement` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `true`)
|
||||
- `withoutEnlargement` **[Boolean][14]** (optional, default `true`)
|
||||
|
||||
Returns **Sharp**
|
||||
|
||||
[1]: #resize
|
||||
|
||||
[2]: #crop
|
||||
|
||||
[3]: #embed
|
||||
|
||||
[4]: #max
|
||||
|
||||
[5]: #min
|
||||
|
||||
[6]: #ignoreaspectratio
|
||||
|
||||
[7]: #withoutenlargement
|
||||
|
||||
[8]: http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation
|
||||
|
||||
[9]: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline
|
||||
|
||||
[10]: https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel
|
||||
|
||||
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
|
||||
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[16]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
### Table of Contents
|
||||
|
||||
- [cache](#cache)
|
||||
- [concurrency](#concurrency)
|
||||
- [counters](#counters)
|
||||
- [simd](#simd)
|
||||
- [cache][1]
|
||||
- [concurrency][2]
|
||||
- [counters][3]
|
||||
- [simd][4]
|
||||
|
||||
## cache
|
||||
|
||||
@@ -16,10 +16,10 @@ useful for determining how much working memory is required for a particular task
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `options` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))** Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default `true`)
|
||||
- `options.memory` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** is the maximum memory in MB to use for this cache (optional, default `50`)
|
||||
- `options.files` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** is the maximum number of files to hold open (optional, default `20`)
|
||||
- `options.items` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** is the maximum number of operations to cache (optional, default `100`)
|
||||
- `options` **([Object][5] \| [Boolean][6])** Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default `true`)
|
||||
- `options.memory` **[Number][7]** is the maximum memory in MB to use for this cache (optional, default `50`)
|
||||
- `options.files` **[Number][7]** is the maximum number of files to hold open (optional, default `20`)
|
||||
- `options.items` **[Number][7]** is the maximum number of operations to cache (optional, default `100`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -33,7 +33,7 @@ sharp.cache( { files: 0 } );
|
||||
sharp.cache(false);
|
||||
```
|
||||
|
||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||
Returns **[Object][5]**
|
||||
|
||||
## concurrency
|
||||
|
||||
@@ -49,7 +49,7 @@ This method always returns the current concurrency.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `concurrency` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?**
|
||||
- `concurrency` **[Number][7]?**
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -59,7 +59,7 @@ sharp.concurrency(2); // 2
|
||||
sharp.concurrency(0); // 4
|
||||
```
|
||||
|
||||
Returns **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** concurrency
|
||||
Returns **[Number][7]** concurrency
|
||||
|
||||
## counters
|
||||
|
||||
@@ -74,7 +74,7 @@ Provides access to internal task counters.
|
||||
const counters = sharp.counters(); // { queue: 2, process: 4 }
|
||||
```
|
||||
|
||||
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||
Returns **[Object][5]**
|
||||
|
||||
## simd
|
||||
|
||||
@@ -89,7 +89,7 @@ Versions of liborc prior to 0.4.25 are known to segfault under heavy load.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `simd` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `false`)
|
||||
- `simd` **[Boolean][6]** (optional, default `false`)
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -103,4 +103,18 @@ const simd = sharp.simd(true);
|
||||
// attempts to enable the use of SIMD, returning true if available
|
||||
```
|
||||
|
||||
Returns **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
|
||||
Returns **[Boolean][6]**
|
||||
|
||||
[1]: #cache
|
||||
|
||||
[2]: #concurrency
|
||||
|
||||
[3]: #counters
|
||||
|
||||
[4]: #simd
|
||||
|
||||
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
||||
|
||||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
### v0.20 - "*teeth*"
|
||||
|
||||
#### v0.20.0 - TBD
|
||||
|
||||
* Add support for prebuilt sharp binaries on common platforms.
|
||||
[#186](https://github.com/lovell/sharp/issues/186)
|
||||
|
||||
### v0.19 - "*suit*"
|
||||
|
||||
Requires libvips v8.6.1.
|
||||
|
||||
@@ -13,8 +13,9 @@ Lanczos resampling ensures quality is not sacrificed for speed.
|
||||
As well as image resizing, operations such as
|
||||
rotation, extraction, compositing and gamma correction are available.
|
||||
|
||||
OS X, Windows (x64), Linux (x64, ARM) systems do not require
|
||||
the installation of any external runtime dependencies.
|
||||
Most 64-bit OS X, Windows and Linux (glibc) systems running
|
||||
Node versions 4, 6, 8 and 9
|
||||
do not require any additional install or runtime dependencies.
|
||||
|
||||
[](https://coveralls.io/r/lovell/sharp?branch=master)
|
||||
|
||||
@@ -46,7 +47,7 @@ are held in memory and processed at a time,
|
||||
taking full advantage of multiple CPU cores and L1/L2/L3 cache.
|
||||
|
||||
Everything remains non-blocking thanks to _libuv_,
|
||||
no child processes are spawned and Promises/A+ are supported.
|
||||
no child processes are spawned and Promises/async/await are supported.
|
||||
|
||||
### Optimal
|
||||
|
||||
|
||||
@@ -8,12 +8,29 @@ npm install sharp
|
||||
yarn add sharp
|
||||
```
|
||||
|
||||
### Prerequisites
|
||||
## Prerequisites
|
||||
|
||||
* Node v4.5.0+
|
||||
|
||||
### Building from source
|
||||
|
||||
Pre-compiled binaries for sharp are provided for use with
|
||||
Node versions 4, 6, 8 and 9 on
|
||||
64-bit Windows, OS X and Linux platforms.
|
||||
|
||||
Sharp will be built from source at install time when:
|
||||
|
||||
* a globally-installed libvips is detected,
|
||||
* pre-compiled binaries do not exist for the current platform and Node version, or
|
||||
* when the `npm install --build-from-source` flag is used.
|
||||
|
||||
Building from source requires:
|
||||
|
||||
* C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+
|
||||
* [node-gyp](https://github.com/TooTallNate/node-gyp#installation) and its dependencies (includes Python)
|
||||
|
||||
## libvips
|
||||
|
||||
### Linux
|
||||
|
||||
[](https://travis-ci.org/lovell/sharp)
|
||||
@@ -23,14 +40,14 @@ This involves an automated HTTPS download of approximately 7MB.
|
||||
|
||||
Most recent Linux-based operating systems with glibc running on x64 and ARMv6+ CPUs should "just work", e.g.:
|
||||
|
||||
* Debian 7, 8
|
||||
* Ubuntu 14.04, 16.04
|
||||
* Centos 7
|
||||
* Debian 7+
|
||||
* Ubuntu 14.04+
|
||||
* Centos 7+
|
||||
* Fedora
|
||||
* openSUSE 13.2
|
||||
* openSUSE 13.2+
|
||||
* Archlinux
|
||||
* Raspbian Jessie
|
||||
* Amazon Linux 2017.03.1
|
||||
* Amazon Linux
|
||||
* Solus
|
||||
|
||||
To use a globally-installed version of libvips instead of the provided binaries,
|
||||
@@ -63,7 +80,7 @@ via `sharp.cache(false)` to avoid a stack overflow.
|
||||
|
||||
### Mac OS
|
||||
|
||||
[](https://travis-ci.org/lovell/sharp)
|
||||
[](https://travis-ci.org/lovell/sharp)
|
||||
|
||||
libvips and its dependencies are fetched and stored within `node_modules/sharp/vendor` during `npm install`.
|
||||
This involves an automated HTTPS download of approximately 7MB.
|
||||
|
||||
Reference in New Issue
Block a user