diff --git a/docs/api-channel.md b/docs/api-channel.md index e71f81aed..011934b25 100644 --- a/docs/api-channel.md +++ b/docs/api-channel.md @@ -1,23 +1,12 @@ -### Table of Contents - -- [extractChannel][1] - - [Parameters][2] - - [Examples][3] -- [joinChannel][4] - - [Parameters][5] -- [bandbool][6] - - [Parameters][7] - - [Examples][8] - ## extractChannel Extract a single channel from a multi-channel image. ### Parameters -- `channel` **([Number][9] \| [String][10])** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively. +- `channel` **([Number][1] \| [String][2])** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively. ### Examples @@ -30,7 +19,7 @@ sharp(input) }); ``` -- Throws **[Error][11]** Invalid channel +- Throws **[Error][3]** Invalid channel Returns **Sharp** @@ -49,11 +38,11 @@ For raw pixel input, the `options` object should contain a `raw` attribute, whic ### Parameters -- `images` **([Array][12]<([String][10] \| [Buffer][13])> | [String][10] \| [Buffer][13])** one or more images (file paths, Buffers). -- `options` **[Object][14]** image options, see `sharp()` constructor. +- `images` **([Array][4]<([String][2] \| [Buffer][5])> | [String][2] \| [Buffer][5])** one or more images (file paths, Buffers). +- `options` **[Object][6]** image options, see `sharp()` constructor. -- Throws **[Error][11]** Invalid parameters +- Throws **[Error][3]** Invalid parameters Returns **Sharp** @@ -63,7 +52,7 @@ Perform a bitwise boolean operation on all input image channels (bands) to produ ### Parameters -- `boolOp` **[String][10]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively. +- `boolOp` **[String][2]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively. ### Examples @@ -77,34 +66,18 @@ sharp('3-channel-rgb-input.png') }); ``` -- Throws **[Error][11]** Invalid parameters +- Throws **[Error][3]** Invalid parameters Returns **Sharp** -[1]: #extractchannel - -[2]: #parameters - -[3]: #examples - -[4]: #joinchannel - -[5]: #parameters-1 - -[6]: #bandbool - -[7]: #parameters-2 - -[8]: #examples-1 - -[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[13]: https://nodejs.org/api/buffer.html +[5]: https://nodejs.org/api/buffer.html -[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api-colour.md b/docs/api-colour.md index 51c0993c3..ca667160c 100644 --- a/docs/api-colour.md +++ b/docs/api-colour.md @@ -1,20 +1,5 @@ -### Table of Contents - -- [background][1] - - [Parameters][2] -- [tint][3] - - [Parameters][4] -- [greyscale][5] - - [Parameters][6] -- [grayscale][7] - - [Parameters][8] -- [toColourspace][9] - - [Parameters][10] -- [toColorspace][11] - - [Parameters][12] - ## background Set the background for the `embed`, `flatten` and `extend` operations. @@ -26,10 +11,10 @@ The alpha value is a float between `0` (transparent) and `1` (opaque). ### Parameters -- `rgba` **([String][13] \| [Object][14])** parsed by the [color][15] module to extract values for red, green, blue and alpha. +- `rgba` **([String][1] \| [Object][2])** parsed by the [color][3] module to extract values for red, green, blue and alpha. -- Throws **[Error][16]** Invalid parameter +- Throws **[Error][4]** Invalid parameter Returns **Sharp** @@ -40,10 +25,10 @@ An alpha channel may be present and will be unchanged by the operation. ### Parameters -- `rgb` **([String][13] \| [Object][14])** parsed by the [color][15] module to extract chroma values. +- `rgb` **([String][1] \| [Object][2])** parsed by the [color][3] module to extract chroma values. -- Throws **[Error][16]** Invalid parameter +- Throws **[Error][4]** Invalid parameter Returns **Sharp** @@ -58,7 +43,7 @@ An alpha channel may be present, and will be unchanged by the operation. ### Parameters -- `greyscale` **[Boolean][17]** (optional, default `true`) +- `greyscale` **[Boolean][5]** (optional, default `true`) Returns **Sharp** @@ -68,7 +53,7 @@ Alternative spelling of `greyscale`. ### Parameters -- `grayscale` **[Boolean][17]** (optional, default `true`) +- `grayscale` **[Boolean][5]** (optional, default `true`) Returns **Sharp** @@ -79,10 +64,10 @@ By default output image will be web-friendly sRGB, with additional channels inte ### Parameters -- `colourspace` **[String][13]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][18] +- `colourspace` **[String][1]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][6] -- Throws **[Error][16]** Invalid parameters +- Throws **[Error][4]** Invalid parameters Returns **Sharp** @@ -92,45 +77,21 @@ Alternative spelling of `toColourspace`. ### Parameters -- `colorspace` **[String][13]?** output colorspace. +- `colorspace` **[String][1]?** output colorspace. -- Throws **[Error][16]** Invalid parameters +- Throws **[Error][4]** Invalid parameters Returns **Sharp** -[1]: #background - -[2]: #parameters - -[3]: #tint - -[4]: #parameters-1 - -[5]: #greyscale - -[6]: #parameters-2 - -[7]: #grayscale - -[8]: #parameters-3 - -[9]: #tocolourspace - -[10]: #parameters-4 - -[11]: #tocolorspace - -[12]: #parameters-5 - -[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[15]: https://www.npmjs.org/package/color +[3]: https://www.npmjs.org/package/color -[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[18]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568 +[6]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568 diff --git a/docs/api-composite.md b/docs/api-composite.md index a01b0bdd7..5de5add4a 100644 --- a/docs/api-composite.md +++ b/docs/api-composite.md @@ -1,11 +1,5 @@ -### Table of Contents - -- [overlayWith][1] - - [Parameters][2] - - [Examples][3] - ## overlayWith Overlay (composite) an image over the processed (resized, extracted etc.) image. @@ -17,23 +11,23 @@ If the overlay image contains an alpha channel then composition with premultipli ### Parameters -- `overlay` **([Buffer][4] \| [String][5])** Buffer containing image data or String containing the path to an image file. -- `options` **[Object][6]?** - - `options.gravity` **[String][5]** gravity at which to place the overlay. (optional, default `'centre'`) - - `options.top` **[Number][7]?** the pixel offset from the top edge. - - `options.left` **[Number][7]?** the pixel offset from the left edge. - - `options.tile` **[Boolean][8]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`) - - `options.cutout` **[Boolean][8]** 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][7]** integral number representing the DPI for vector overlay image. (optional, default `72`) - - `options.raw` **[Object][6]?** describes overlay when using raw pixel data. - - `options.raw.width` **[Number][7]?** - - `options.raw.height` **[Number][7]?** - - `options.raw.channels` **[Number][7]?** - - `options.create` **[Object][6]?** describes a blank overlay to be created. - - `options.create.width` **[Number][7]?** - - `options.create.height` **[Number][7]?** - - `options.create.channels` **[Number][7]?** 3-4 - - `options.create.background` **([String][5] \| [Object][6])?** parsed by the [color][9] module to extract values for red, green, blue and alpha. +- `overlay` **([Buffer][1] \| [String][2])** Buffer containing image data or String containing the path to an image file. +- `options` **[Object][3]?** + - `options.gravity` **[String][2]** gravity at which to place the overlay. (optional, default `'centre'`) + - `options.top` **[Number][4]?** the pixel offset from the top edge. + - `options.left` **[Number][4]?** the pixel offset from the left edge. + - `options.tile` **[Boolean][5]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`) + - `options.cutout` **[Boolean][5]** 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][4]** integral number representing the DPI for vector overlay image. (optional, default `72`) + - `options.raw` **[Object][3]?** describes overlay when using raw pixel data. + - `options.raw.width` **[Number][4]?** + - `options.raw.height` **[Number][4]?** + - `options.raw.channels` **[Number][4]?** + - `options.create` **[Object][3]?** describes a blank overlay to be created. + - `options.create.width` **[Number][4]?** + - `options.create.height` **[Number][4]?** + - `options.create.channels` **[Number][4]?** 3-4 + - `options.create.background` **([String][2] \| [Object][3])?** parsed by the [color][6] module to extract values for red, green, blue and alpha. ### Examples @@ -56,26 +50,20 @@ sharp('input.png') }); ``` -- Throws **[Error][10]** Invalid parameters +- Throws **[Error][7]** Invalid parameters Returns **Sharp** -[1]: #overlaywith - -[2]: #parameters - -[3]: #examples - -[4]: https://nodejs.org/api/buffer.html +[1]: https://nodejs.org/api/buffer.html -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[9]: https://www.npmjs.org/package/color +[6]: https://www.npmjs.org/package/color -[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error diff --git a/docs/api-constructor.md b/docs/api-constructor.md index b1cf64619..f13ad181a 100644 --- a/docs/api-constructor.md +++ b/docs/api-constructor.md @@ -1,40 +1,28 @@ -### Table of Contents - -- [Sharp][1] - - [Parameters][2] - - [Examples][3] - - [format][4] - - [Examples][5] - - [versions][6] - - [Examples][7] -- [queue][8] - - [Examples][9] - ## Sharp ### Parameters -- `input` **([Buffer][10] \| [String][11])?** if present, can be +- `input` **([Buffer][1] \| [String][2])?** 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][12]?** if present, is an Object with optional attributes. - - `options.failOnError` **[Boolean][13]** by default apply a "best effort" +- `options` **[Object][3]?** if present, is an Object with optional attributes. + - `options.failOnError` **[Boolean][4]** 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][14]** integral number representing the DPI for vector images. (optional, default `72`) - - `options.page` **[Number][14]** page number to extract for multi-page input (GIF, TIFF) (optional, default `0`) - - `options.raw` **[Object][12]?** describes raw pixel input image data. See `raw()` for pixel ordering. - - `options.raw.width` **[Number][14]?** - - `options.raw.height` **[Number][14]?** - - `options.raw.channels` **[Number][14]?** 1-4 - - `options.create` **[Object][12]?** describes a new image to be created. - - `options.create.width` **[Number][14]?** - - `options.create.height` **[Number][14]?** - - `options.create.channels` **[Number][14]?** 3-4 - - `options.create.background` **([String][11] \| [Object][12])?** parsed by the [color][15] module to extract values for red, green, blue and alpha. + - `options.density` **[Number][5]** integral number representing the DPI for vector images. (optional, default `72`) + - `options.page` **[Number][5]** page number to extract for multi-page input (GIF, TIFF) (optional, default `0`) + - `options.raw` **[Object][3]?** describes raw pixel input image data. See `raw()` for pixel ordering. + - `options.raw.width` **[Number][5]?** + - `options.raw.height` **[Number][5]?** + - `options.raw.channels` **[Number][5]?** 1-4 + - `options.create` **[Object][3]?** describes a new image to be created. + - `options.create.width` **[Number][5]?** + - `options.create.height` **[Number][5]?** + - `options.create.channels` **[Number][5]?** 3-4 + - `options.create.background` **([String][2] \| [Object][3])?** parsed by the [color][6] module to extract values for red, green, blue and alpha. ### Examples @@ -75,9 +63,9 @@ sharp({ .then( ... ); ``` -- Throws **[Error][16]** Invalid parameters +- Throws **[Error][7]** Invalid parameters -Returns **[Sharp][17]** +Returns **[Sharp][8]** ### format @@ -89,7 +77,7 @@ An Object containing nested boolean values representing the available input and console.log(sharp.format); ``` -Returns **[Object][12]** +Returns **[Object][3]** ### versions @@ -116,36 +104,18 @@ sharp.queue.on('change', function(queueLength) { }); ``` -[1]: #sharp - -[2]: #parameters - -[3]: #examples - -[4]: #format - -[5]: #examples-1 - -[6]: #versions - -[7]: #examples-2 - -[8]: #queue - -[9]: #examples-3 - -[10]: https://nodejs.org/api/buffer.html +[1]: https://nodejs.org/api/buffer.html -[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[15]: https://www.npmjs.org/package/color +[6]: https://www.npmjs.org/package/color -[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[17]: #sharp +[8]: #sharp diff --git a/docs/api-input.md b/docs/api-input.md index 16250d840..a51a5ae72 100644 --- a/docs/api-input.md +++ b/docs/api-input.md @@ -1,20 +1,5 @@ -### Table of Contents - -- [clone][1] - - [Examples][2] -- [metadata][3] - - [Parameters][4] - - [Examples][5] -- [stats][6] - - [Parameters][7] - - [Examples][8] -- [limitInputPixels][9] - - [Parameters][10] -- [sequentialRead][11] - - [Parameters][12] - ## clone Take a "snapshot" of the Sharp instance, returning a new instance. @@ -42,21 +27,21 @@ 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 (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` [...][13] +- `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][1] - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK -- `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...][14] +- `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...][2] - `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][15] profile data, if present +- `icc`: Buffer containing raw [ICC][3] profile data, if present - `iptc`: Buffer containing raw IPTC data, if present - `xmp`: Buffer containing raw XMP data, if present ### Parameters -- `callback` **[Function][16]?** called with the arguments `(err, metadata)` +- `callback` **[Function][4]?** called with the arguments `(err, metadata)` ### Examples @@ -75,7 +60,7 @@ image }); ``` -Returns **([Promise][17]<[Object][18]> | Sharp)** +Returns **([Promise][5]<[Object][6]> | Sharp)** ## stats @@ -97,7 +82,7 @@ A Promise is returned when `callback` is not provided. ### Parameters -- `callback` **[Function][16]?** called with the arguments `(err, stats)` +- `callback` **[Function][4]?** called with the arguments `(err, stats)` ### Examples @@ -110,7 +95,7 @@ image }); ``` -Returns **[Promise][17]<[Object][18]>** +Returns **[Promise][5]<[Object][6]>** ## limitInputPixels @@ -120,10 +105,10 @@ The default limit is 268402689 (0x3FFF _ 0x3FFF) pixels. ### Parameters -- `limit` **([Number][19] \| [Boolean][20])** an integral Number of pixels, zero or false to remove limit, true to use default limit. +- `limit` **([Number][7] \| [Boolean][8])** an integral Number of pixels, zero or false to remove limit, true to use default limit. -- Throws **[Error][21]** Invalid limit +- Throws **[Error][9]** Invalid limit Returns **Sharp** @@ -136,48 +121,24 @@ The default behaviour _before_ function call is `false`, meaning the libvips acc ### Parameters -- `sequentialRead` **[Boolean][20]** (optional, default `true`) +- `sequentialRead` **[Boolean][8]** (optional, default `true`) Returns **Sharp** -[1]: #clone - -[2]: #examples - -[3]: #metadata - -[4]: #parameters - -[5]: #examples-1 - -[6]: #stats - -[7]: #parameters-1 - -[8]: #examples-2 - -[9]: #limitinputpixels - -[10]: #parameters-2 - -[11]: #sequentialread - -[12]: #parameters-3 - -[13]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L636 +[1]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L636 -[14]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L672 +[2]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L672 -[15]: https://www.npmjs.com/package/icc +[3]: https://www.npmjs.com/package/icc -[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error diff --git a/docs/api-operation.md b/docs/api-operation.md index a96343927..ff4a478e0 100644 --- a/docs/api-operation.md +++ b/docs/api-operation.md @@ -1,48 +1,5 @@ -### Table of Contents - -- [rotate][1] - - [Parameters][2] - - [Examples][3] -- [extract][4] - - [Parameters][5] - - [Examples][6] -- [flip][7] - - [Parameters][8] -- [flop][9] - - [Parameters][10] -- [sharpen][11] - - [Parameters][12] -- [median][13] - - [Parameters][14] -- [blur][15] - - [Parameters][16] -- [extend][17] - - [Parameters][18] - - [Examples][19] -- [flatten][20] - - [Parameters][21] -- [trim][22] - - [Parameters][23] -- [gamma][24] - - [Parameters][25] -- [negate][26] - - [Parameters][27] -- [normalise][28] - - [Parameters][29] -- [normalize][30] - - [Parameters][31] -- [convolve][32] - - [Parameters][33] - - [Examples][34] -- [threshold][35] - - [Parameters][36] -- [boolean][37] - - [Parameters][38] -- [linear][39] - - [Parameters][40] - ## rotate Rotate the output image by either an explicit angle @@ -61,7 +18,7 @@ for example `rotate(x).extract(y)` will produce a different result to `extract(y ### Parameters -- `angle` **[Number][41]** angle of rotation, must be a multiple of 90. (optional, default `auto`) +- `angle` **[Number][1]** angle of rotation, must be a multiple of 90. (optional, default `auto`) ### Examples @@ -77,7 +34,7 @@ const pipeline = sharp() readableStream.pipe(pipeline); ``` -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -91,11 +48,11 @@ Extract a region of the image. ### Parameters -- `options` **[Object][43]** - - `options.left` **[Number][41]** zero-indexed offset from left edge - - `options.top` **[Number][41]** zero-indexed offset from top edge - - `options.width` **[Number][41]** dimension of extracted image - - `options.height` **[Number][41]** dimension of extracted image +- `options` **[Object][3]** + - `options.left` **[Number][1]** zero-indexed offset from left edge + - `options.top` **[Number][1]** zero-indexed offset from top edge + - `options.width` **[Number][1]** dimension of extracted image + - `options.height` **[Number][1]** dimension of extracted image ### Examples @@ -117,7 +74,7 @@ sharp(input) }); ``` -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -128,7 +85,7 @@ The use of `flip` implies the removal of the EXIF `Orientation` tag, if any. ### Parameters -- `flip` **[Boolean][44]** (optional, default `true`) +- `flip` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -139,7 +96,7 @@ The use of `flop` implies the removal of the EXIF `Orientation` tag, if any. ### Parameters -- `flop` **[Boolean][44]** (optional, default `true`) +- `flop` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -152,12 +109,12 @@ Separate control over the level of sharpening in "flat" and "jagged" areas is av ### Parameters -- `sigma` **[Number][41]?** the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`. -- `flat` **[Number][41]** the level of sharpening to apply to "flat" areas. (optional, default `1.0`) -- `jagged` **[Number][41]** the level of sharpening to apply to "jagged" areas. (optional, default `2.0`) +- `sigma` **[Number][1]?** the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`. +- `flat` **[Number][1]** the level of sharpening to apply to "flat" areas. (optional, default `1.0`) +- `jagged` **[Number][1]** the level of sharpening to apply to "jagged" areas. (optional, default `2.0`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -168,10 +125,10 @@ When used without parameters the default window is 3x3. ### Parameters -- `size` **[Number][41]** square mask size: size x size (optional, default `3`) +- `size` **[Number][1]** square mask size: size x size (optional, default `3`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -183,10 +140,10 @@ When a `sigma` is provided, performs a slower, more accurate Gaussian blur. ### Parameters -- `sigma` **[Number][41]?** a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`. +- `sigma` **[Number][1]?** a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`. -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -197,11 +154,11 @@ This operation will always occur after resizing and extraction, if any. ### Parameters -- `extend` **([Number][41] \| [Object][43])** single pixel count to add to all edges or an Object with per-edge counts - - `extend.top` **[Number][41]?** - - `extend.left` **[Number][41]?** - - `extend.bottom` **[Number][41]?** - - `extend.right` **[Number][41]?** +- `extend` **([Number][1] \| [Object][3])** single pixel count to add to all edges or an Object with per-edge counts + - `extend.top` **[Number][1]?** + - `extend.left` **[Number][1]?** + - `extend.bottom` **[Number][1]?** + - `extend.right` **[Number][1]?** ### Examples @@ -215,7 +172,7 @@ sharp(input) ... ``` -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -225,7 +182,7 @@ Merge alpha transparency channel, if any, with `background`. ### Parameters -- `flatten` **[Boolean][44]** (optional, default `true`) +- `flatten` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -235,10 +192,10 @@ Trim "boring" pixels from all edges that contain values within a percentage simi ### Parameters -- `tolerance` **[Number][41]** value between 1 and 99 representing the percentage similarity. (optional, default `10`) +- `tolerance` **[Number][1]** value between 1 and 99 representing the percentage similarity. (optional, default `10`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -252,10 +209,10 @@ when applying a gamma correction. ### Parameters -- `gamma` **[Number][41]** value between 1.0 and 3.0. (optional, default `2.2`) +- `gamma` **[Number][1]** value between 1.0 and 3.0. (optional, default `2.2`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -265,7 +222,7 @@ Produce the "negative" of the image. ### Parameters -- `negate` **[Boolean][44]** (optional, default `true`) +- `negate` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -275,7 +232,7 @@ Enhance output image contrast by stretching its luminance to cover the full dyna ### Parameters -- `normalise` **[Boolean][44]** (optional, default `true`) +- `normalise` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -285,7 +242,7 @@ Alternative spelling of normalise. ### Parameters -- `normalize` **[Boolean][44]** (optional, default `true`) +- `normalize` **[Boolean][4]** (optional, default `true`) Returns **Sharp** @@ -295,12 +252,12 @@ Convolve the image with the specified kernel. ### Parameters -- `kernel` **[Object][43]** - - `kernel.width` **[Number][41]** width of the kernel in pixels. - - `kernel.height` **[Number][41]** width of the kernel in pixels. - - `kernel.kernel` **[Array][45]<[Number][41]>** Array of length `width*height` containing the kernel values. - - `kernel.scale` **[Number][41]** the scale of the kernel in pixels. (optional, default `sum`) - - `kernel.offset` **[Number][41]** the offset of the kernel in pixels. (optional, default `0`) +- `kernel` **[Object][3]** + - `kernel.width` **[Number][1]** width of the kernel in pixels. + - `kernel.height` **[Number][1]** width of the kernel in pixels. + - `kernel.kernel` **[Array][5]<[Number][1]>** Array of length `width*height` containing the kernel values. + - `kernel.scale` **[Number][1]** the scale of the kernel in pixels. (optional, default `sum`) + - `kernel.offset` **[Number][1]** the offset of the kernel in pixels. (optional, default `0`) ### Examples @@ -318,7 +275,7 @@ sharp(input) }); ``` -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -328,13 +285,13 @@ Any pixel value greather than or equal to the threshold value will be set to 255 ### Parameters -- `threshold` **[Number][41]** a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default `128`) -- `options` **[Object][43]?** - - `options.greyscale` **[Boolean][44]** convert to single channel greyscale. (optional, default `true`) - - `options.grayscale` **[Boolean][44]** alternative spelling for greyscale. (optional, default `true`) +- `threshold` **[Number][1]** a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default `128`) +- `options` **[Object][3]?** + - `options.greyscale` **[Boolean][4]** convert to single channel greyscale. (optional, default `true`) + - `options.grayscale` **[Boolean][4]** alternative spelling for greyscale. (optional, default `true`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -347,16 +304,16 @@ the selected bitwise boolean `operation` between the corresponding pixels of the ### Parameters -- `operand` **([Buffer][46] \| [String][47])** Buffer containing image data or String containing the path to an image file. -- `operator` **[String][47]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively. -- `options` **[Object][43]?** - - `options.raw` **[Object][43]?** describes operand when using raw pixel data. - - `options.raw.width` **[Number][41]?** - - `options.raw.height` **[Number][41]?** - - `options.raw.channels` **[Number][41]?** +- `operand` **([Buffer][6] \| [String][7])** Buffer containing image data or String containing the path to an image file. +- `operator` **[String][7]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively. +- `options` **[Object][3]?** + - `options.raw` **[Object][3]?** describes operand when using raw pixel data. + - `options.raw.width` **[Number][1]?** + - `options.raw.height` **[Number][1]?** + - `options.raw.channels` **[Number][1]?** -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** @@ -366,104 +323,24 @@ Apply the linear formula a \* input + b to the image (levels adjustment) ### Parameters -- `a` **[Number][41]** multiplier (optional, default `1.0`) -- `b` **[Number][41]** offset (optional, default `0.0`) +- `a` **[Number][1]** multiplier (optional, default `1.0`) +- `b` **[Number][1]** offset (optional, default `0.0`) -- Throws **[Error][42]** Invalid parameters +- Throws **[Error][2]** Invalid parameters Returns **Sharp** -[1]: #rotate - -[2]: #parameters - -[3]: #examples - -[4]: #extract - -[5]: #parameters-1 - -[6]: #examples-1 - -[7]: #flip - -[8]: #parameters-2 - -[9]: #flop - -[10]: #parameters-3 - -[11]: #sharpen - -[12]: #parameters-4 - -[13]: #median - -[14]: #parameters-5 - -[15]: #blur - -[16]: #parameters-6 - -[17]: #extend - -[18]: #parameters-7 - -[19]: #examples-2 - -[20]: #flatten - -[21]: #parameters-8 - -[22]: #trim - -[23]: #parameters-9 - -[24]: #gamma - -[25]: #parameters-10 - -[26]: #negate - -[27]: #parameters-11 - -[28]: #normalise - -[29]: #parameters-12 - -[30]: #normalize - -[31]: #parameters-13 - -[32]: #convolve - -[33]: #parameters-14 - -[34]: #examples-3 - -[35]: #threshold - -[36]: #parameters-15 - -[37]: #boolean - -[38]: #parameters-16 - -[39]: #linear - -[40]: #parameters-17 - -[41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[43]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[44]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[45]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[46]: https://nodejs.org/api/buffer.html +[6]: https://nodejs.org/api/buffer.html -[47]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String diff --git a/docs/api-output.md b/docs/api-output.md index fb88bcf3d..2c1b3f693 100644 --- a/docs/api-output.md +++ b/docs/api-output.md @@ -1,37 +1,5 @@ -### Table of Contents - -- [toFile][1] - - [Parameters][2] - - [Examples][3] -- [toBuffer][4] - - [Parameters][5] - - [Examples][6] -- [withMetadata][7] - - [Parameters][8] - - [Examples][9] -- [jpeg][10] - - [Parameters][11] - - [Examples][12] -- [png][13] - - [Parameters][14] - - [Examples][15] -- [webp][16] - - [Parameters][17] - - [Examples][18] -- [tiff][19] - - [Parameters][20] - - [Examples][21] -- [raw][22] - - [Examples][23] -- [toFormat][24] - - [Parameters][25] - - [Examples][26] -- [tile][27] - - [Parameters][28] - - [Examples][29] - ## toFile Write output image data to a file. @@ -44,8 +12,8 @@ A `Promise` is returned when `callback` is not provided. ### Parameters -- `fileOut` **[String][30]** the path to write the image data to. -- `callback` **[Function][31]?** called on completion with two arguments `(err, info)`. +- `fileOut` **[String][1]** the path to write the image data to. +- `callback` **[Function][2]?** 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`. @@ -64,9 +32,9 @@ sharp(input) .catch(err => { ... }); ``` -- Throws **[Error][32]** Invalid parameters +- Throws **[Error][3]** Invalid parameters -Returns **[Promise][33]<[Object][34]>** when no callback is provided +Returns **[Promise][4]<[Object][5]>** when no callback is provided ## toBuffer @@ -86,9 +54,9 @@ A `Promise` is returned when `callback` is not provided. ### Parameters -- `options` **[Object][34]?** - - `options.resolveWithObject` **[Boolean][35]?** Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`. -- `callback` **[Function][31]?** +- `options` **[Object][5]?** + - `options.resolveWithObject` **[Boolean][6]?** Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`. +- `callback` **[Function][2]?** ### Examples @@ -111,7 +79,7 @@ sharp(input) .catch(err => { ... }); ``` -Returns **[Promise][33]<[Buffer][36]>** when no callback is provided +Returns **[Promise][4]<[Buffer][7]>** when no callback is provided ## withMetadata @@ -121,8 +89,8 @@ This will also convert to and add a web-friendly sRGB ICC profile. ### Parameters -- `withMetadata` **[Object][34]?** - - `withMetadata.orientation` **[Number][37]?** value between 1 and 8, used to update the EXIF `Orientation` tag. +- `withMetadata` **[Object][5]?** + - `withMetadata.orientation` **[Number][8]?** value between 1 and 8, used to update the EXIF `Orientation` tag. ### Examples @@ -133,7 +101,7 @@ sharp('input.jpg') .then(info => { ... }); ``` -- Throws **[Error][32]** Invalid parameters +- Throws **[Error][3]** Invalid parameters Returns **Sharp** @@ -143,15 +111,17 @@ Use these JPEG options for output image. ### Parameters -- `options` **[Object][34]?** output options - - `options.quality` **[Number][37]** quality, integer 1-100 (optional, default `80`) - - `options.progressive` **[Boolean][35]** use progressive (interlace) scan (optional, default `false`) - - `options.chromaSubsampling` **[String][30]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`) - - `options.trellisQuantisation` **[Boolean][35]** apply trellis quantisation, requires mozjpeg (optional, default `false`) - - `options.overshootDeringing` **[Boolean][35]** apply overshoot deringing, requires mozjpeg (optional, default `false`) - - `options.optimiseScans` **[Boolean][35]** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`) - - `options.optimizeScans` **[Boolean][35]** alternative spelling of optimiseScans (optional, default `false`) - - `options.force` **[Boolean][35]** force JPEG output, otherwise attempt to use input format (optional, default `true`) +- `options` **[Object][5]?** output options + - `options.quality` **[Number][8]** quality, integer 1-100 (optional, default `80`) + - `options.progressive` **[Boolean][6]** use progressive (interlace) scan (optional, default `false`) + - `options.chromaSubsampling` **[String][1]** set to '4:4:4' to prevent chroma subsampling when quality <= 90 (optional, default `'4:2:0'`) + - `options.trellisQuantisation` **[Boolean][6]** apply trellis quantisation, requires mozjpeg (optional, default `false`) + - `options.overshootDeringing` **[Boolean][6]** apply overshoot deringing, requires mozjpeg (optional, default `false`) + - `options.optimiseScans` **[Boolean][6]** optimise progressive scans, forces progressive, requires mozjpeg (optional, default `false`) + - `options.optimizeScans` **[Boolean][6]** alternative spelling of optimiseScans (optional, default `false`) + - `options.optimiseCoding` **[Boolean][6]** optimise Huffman coding tables (optional, default `true`) + - `options.optimizeCoding` **[Boolean][6]** alternative spelling of optimiseCoding (optional, default `true`) + - `options.force` **[Boolean][6]** force JPEG output, otherwise attempt to use input format (optional, default `true`) ### Examples @@ -165,7 +135,7 @@ const data = await sharp(input) .toBuffer(); ``` -- Throws **[Error][32]** Invalid options +- Throws **[Error][3]** Invalid options Returns **Sharp** @@ -178,11 +148,11 @@ Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel. ### Parameters -- `options` **[Object][34]?** - - `options.progressive` **[Boolean][35]** use progressive (interlace) scan (optional, default `false`) - - `options.compressionLevel` **[Number][37]** zlib compression level, 0-9 (optional, default `9`) - - `options.adaptiveFiltering` **[Boolean][35]** use adaptive row filtering (optional, default `false`) - - `options.force` **[Boolean][35]** force PNG output, otherwise attempt to use input format (optional, default `true`) +- `options` **[Object][5]?** + - `options.progressive` **[Boolean][6]** use progressive (interlace) scan (optional, default `false`) + - `options.compressionLevel` **[Number][8]** zlib compression level, 0-9 (optional, default `9`) + - `options.adaptiveFiltering` **[Boolean][6]** use adaptive row filtering (optional, default `false`) + - `options.force` **[Boolean][6]** force PNG output, otherwise attempt to use input format (optional, default `true`) ### Examples @@ -193,7 +163,7 @@ const data = await sharp(input) .toBuffer(); ``` -- Throws **[Error][32]** Invalid options +- Throws **[Error][3]** Invalid options Returns **Sharp** @@ -203,12 +173,12 @@ Use these WebP options for output image. ### Parameters -- `options` **[Object][34]?** output options - - `options.quality` **[Number][37]** quality, integer 1-100 (optional, default `80`) - - `options.alphaQuality` **[Number][37]** quality of alpha layer, integer 0-100 (optional, default `100`) - - `options.lossless` **[Boolean][35]** use lossless compression mode (optional, default `false`) - - `options.nearLossless` **[Boolean][35]** use near_lossless compression mode (optional, default `false`) - - `options.force` **[Boolean][35]** force WebP output, otherwise attempt to use input format (optional, default `true`) +- `options` **[Object][5]?** output options + - `options.quality` **[Number][8]** quality, integer 1-100 (optional, default `80`) + - `options.alphaQuality` **[Number][8]** quality of alpha layer, integer 0-100 (optional, default `100`) + - `options.lossless` **[Boolean][6]** use lossless compression mode (optional, default `false`) + - `options.nearLossless` **[Boolean][6]** use near_lossless compression mode (optional, default `false`) + - `options.force` **[Boolean][6]** force WebP output, otherwise attempt to use input format (optional, default `true`) ### Examples @@ -219,7 +189,7 @@ const data = await sharp(input) .toBuffer(); ``` -- Throws **[Error][32]** Invalid options +- Throws **[Error][3]** Invalid options Returns **Sharp** @@ -229,14 +199,14 @@ Use these TIFF options for output image. ### Parameters -- `options` **[Object][34]?** output options - - `options.quality` **[Number][37]** quality, integer 1-100 (optional, default `80`) - - `options.force` **[Boolean][35]** force TIFF output, otherwise attempt to use input format (optional, default `true`) - - `options.compression` **[Boolean][35]** compression options: lzw, deflate, jpeg, ccittfax4 (optional, default `'jpeg'`) - - `options.predictor` **[Boolean][35]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`) - - `options.xres` **[Number][37]** horizontal resolution in pixels/mm (optional, default `1.0`) - - `options.yres` **[Number][37]** vertical resolution in pixels/mm (optional, default `1.0`) - - `options.squash` **[Boolean][35]** squash 8-bit images down to 1 bit (optional, default `false`) +- `options` **[Object][5]?** output options + - `options.quality` **[Number][8]** quality, integer 1-100 (optional, default `80`) + - `options.force` **[Boolean][6]** force TIFF output, otherwise attempt to use input format (optional, default `true`) + - `options.compression` **[Boolean][6]** compression options: lzw, deflate, jpeg, ccittfax4 (optional, default `'jpeg'`) + - `options.predictor` **[Boolean][6]** compression predictor options: none, horizontal, float (optional, default `'horizontal'`) + - `options.xres` **[Number][8]** horizontal resolution in pixels/mm (optional, default `1.0`) + - `options.yres` **[Number][8]** vertical resolution in pixels/mm (optional, default `1.0`) + - `options.squash` **[Boolean][6]** squash 8-bit images down to 1 bit (optional, default `false`) ### Examples @@ -251,7 +221,7 @@ sharp('input.svg') .then(info => { ... }); ``` -- Throws **[Error][32]** Invalid options +- Throws **[Error][3]** Invalid options Returns **Sharp** @@ -276,8 +246,8 @@ Force output to a given format. ### Parameters -- `format` **([String][30] \| [Object][34])** as a String or an Object with an 'id' attribute -- `options` **[Object][34]** output options +- `format` **([String][1] \| [Object][5])** as a String or an Object with an 'id' attribute +- `options` **[Object][5]** output options ### Examples @@ -288,7 +258,7 @@ const data = await sharp(input) .toBuffer(); ``` -- Throws **[Error][32]** unsupported format or options +- Throws **[Error][3]** unsupported format or options Returns **Sharp** @@ -302,12 +272,12 @@ Warning: multiple sharp instances concurrently producing tile output can expose ### Parameters -- `tile` **[Object][34]?** - - `tile.size` **[Number][37]** tile size in pixels, a value between 1 and 8192. (optional, default `256`) - - `tile.overlap` **[Number][37]** tile overlap in pixels, a value between 0 and 8192. (optional, default `0`) - - `tile.angle` **[Number][37]** tile angle of rotation, must be a multiple of 90. (optional, default `0`) - - `tile.container` **[String][30]** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`) - - `tile.layout` **[String][30]** filesystem layout, possible values are `dz`, `zoomify` or `google`. (optional, default `'dz'`) +- `tile` **[Object][5]?** + - `tile.size` **[Number][8]** tile size in pixels, a value between 1 and 8192. (optional, default `256`) + - `tile.overlap` **[Number][8]** tile overlap in pixels, a value between 0 and 8192. (optional, default `0`) + - `tile.angle` **[Number][8]** tile angle of rotation, must be a multiple of 90. (optional, default `0`) + - `tile.container` **[String][1]** tile container, with value `fs` (filesystem) or `zip` (compressed file). (optional, default `'fs'`) + - `tile.layout` **[String][1]** filesystem layout, possible values are `dz`, `zoomify` or `google`. (optional, default `'dz'`) ### Examples @@ -323,80 +293,22 @@ sharp('input.tiff') }); ``` -- Throws **[Error][32]** Invalid parameters +- Throws **[Error][3]** Invalid parameters Returns **Sharp** -[1]: #tofile - -[2]: #parameters - -[3]: #examples - -[4]: #tobuffer - -[5]: #parameters-1 - -[6]: #examples-1 - -[7]: #withmetadata - -[8]: #parameters-2 - -[9]: #examples-2 - -[10]: #jpeg - -[11]: #parameters-3 - -[12]: #examples-3 - -[13]: #png - -[14]: #parameters-4 - -[15]: #examples-4 - -[16]: #webp - -[17]: #parameters-5 - -[18]: #examples-5 - -[19]: #tiff - -[20]: #parameters-6 - -[21]: #examples-6 - -[22]: #raw - -[23]: #examples-7 - -[24]: #toformat - -[25]: #parameters-7 - -[26]: #examples-8 - -[27]: #tile - -[28]: #parameters-8 - -[29]: #examples-9 - -[30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[31]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[33]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[34]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[35]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[36]: https://nodejs.org/api/buffer.html +[7]: https://nodejs.org/api/buffer.html -[37]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/docs/api-resize.md b/docs/api-resize.md index 576329c77..b2a979e0f 100644 --- a/docs/api-resize.md +++ b/docs/api-resize.md @@ -1,23 +1,5 @@ -### Table of Contents - -- [resize][1] - - [Parameters][2] - - [Examples][3] -- [crop][4] - - [Parameters][5] - - [Examples][6] -- [embed][7] - - [Parameters][8] - - [Examples][9] -- [max][10] - - [Examples][11] -- [min][12] -- [ignoreAspectRatio][13] -- [withoutEnlargement][14] - - [Parameters][15] - ## resize Resize image to `width` x `height`. @@ -25,18 +7,18 @@ By default, the resized image is centre cropped to the exact size specified. Possible kernels are: -- `nearest`: Use [nearest neighbour interpolation][16]. -- `cubic`: Use a [Catmull-Rom spline][17]. -- `lanczos2`: Use a [Lanczos kernel][18] with `a=2`. +- `nearest`: Use [nearest neighbour interpolation][1]. +- `cubic`: Use a [Catmull-Rom spline][2]. +- `lanczos2`: Use a [Lanczos kernel][3] with `a=2`. - `lanczos3`: Use a Lanczos kernel with `a=3` (the default). ### Parameters -- `width` **[Number][19]?** pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height. -- `height` **[Number][19]?** pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width. -- `options` **[Object][20]?** - - `options.kernel` **[String][21]** the kernel to use for image reduction. (optional, default `'lanczos3'`) - - `options.fastShrinkOnLoad` **[Boolean][22]** 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][4]?** pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height. +- `height` **[Number][4]?** pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width. +- `options` **[Object][5]?** + - `options.kernel` **[String][6]** the kernel to use for image reduction. (optional, default `'lanczos3'`) + - `options.fastShrinkOnLoad` **[Boolean][7]** 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 @@ -55,7 +37,7 @@ sharp(inputBuffer) }); ``` -- Throws **[Error][23]** Invalid parameters +- Throws **[Error][8]** Invalid parameters Returns **Sharp** @@ -69,12 +51,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][24]. +- `entropy`: focus on the region with the highest [Shannon entropy][9]. - `attention`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones. ### Parameters -- `crop` **[String][21]** A member of `sharp.gravity` to crop to an edge/corner or `sharp.strategy` to crop dynamically. (optional, default `'centre'`) +- `crop` **[String][6]** A member of `sharp.gravity` to crop to an edge/corner or `sharp.strategy` to crop dynamically. (optional, default `'centre'`) ### Examples @@ -90,7 +72,7 @@ const transformer = sharp() readableStream.pipe(transformer).pipe(writableStream); ``` -- Throws **[Error][23]** Invalid parameters +- Throws **[Error][8]** Invalid parameters Returns **Sharp** @@ -104,7 +86,7 @@ contain an alpha channel, even when the input image does not. ### Parameters -- `embed` **[String][21]** A member of `sharp.gravity` to embed to an edge/corner. (optional, default `'centre'`) +- `embed` **[String][6]** A member of `sharp.gravity` to embed to an edge/corner. (optional, default `'centre'`) ### Examples @@ -123,7 +105,7 @@ sharp('input.gif') }); ``` -- Throws **[Error][23]** Invalid parameters +- Throws **[Error][8]** Invalid parameters Returns **Sharp** @@ -177,54 +159,24 @@ The default behaviour _before_ function call is `false`, meaning the image will ### Parameters -- `withoutEnlargement` **[Boolean][22]** (optional, default `true`) +- `withoutEnlargement` **[Boolean][7]** (optional, default `true`) Returns **Sharp** -[1]: #resize - -[2]: #parameters - -[3]: #examples - -[4]: #crop - -[5]: #parameters-1 - -[6]: #examples-1 - -[7]: #embed - -[8]: #parameters-2 - -[9]: #examples-2 - -[10]: #max - -[11]: #examples-3 - -[12]: #min - -[13]: #ignoreaspectratio - -[14]: #withoutenlargement - -[15]: #parameters-3 - -[16]: http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation +[1]: http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation -[17]: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline +[2]: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline -[18]: https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel +[3]: https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel -[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[24]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29 +[9]: https://en.wikipedia.org/wiki/Entropy_%28information_theory%29 diff --git a/docs/api-utility.md b/docs/api-utility.md index acc6bb5a1..a2af0c08c 100644 --- a/docs/api-utility.md +++ b/docs/api-utility.md @@ -1,19 +1,5 @@ -### Table of Contents - -- [cache][1] - - [Parameters][2] - - [Examples][3] -- [concurrency][4] - - [Parameters][5] - - [Examples][6] -- [counters][7] - - [Examples][8] -- [simd][9] - - [Parameters][10] - - [Examples][11] - ## cache Gets or, when options are provided, sets the limits of _libvips'_ operation cache. @@ -23,10 +9,10 @@ useful for determining how much working memory is required for a particular task ### Parameters -- `options` **([Object][12] \| [Boolean][13])** Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default `true`) - - `options.memory` **[Number][14]** is the maximum memory in MB to use for this cache (optional, default `50`) - - `options.files` **[Number][14]** is the maximum number of files to hold open (optional, default `20`) - - `options.items` **[Number][14]** is the maximum number of operations to cache (optional, default `100`) +- `options` **([Object][1] \| [Boolean][2])** Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default `true`) + - `options.memory` **[Number][3]** is the maximum memory in MB to use for this cache (optional, default `50`) + - `options.files` **[Number][3]** is the maximum number of files to hold open (optional, default `20`) + - `options.items` **[Number][3]** is the maximum number of operations to cache (optional, default `100`) ### Examples @@ -40,7 +26,7 @@ sharp.cache( { files: 0 } ); sharp.cache(false); ``` -Returns **[Object][12]** +Returns **[Object][1]** ## concurrency @@ -56,7 +42,7 @@ This method always returns the current concurrency. ### Parameters -- `concurrency` **[Number][14]?** +- `concurrency` **[Number][3]?** ### Examples @@ -66,7 +52,7 @@ sharp.concurrency(2); // 2 sharp.concurrency(0); // 4 ``` -Returns **[Number][14]** concurrency +Returns **[Number][3]** concurrency ## counters @@ -81,7 +67,7 @@ Provides access to internal task counters. const counters = sharp.counters(); // { queue: 2, process: 4 } ``` -Returns **[Object][12]** +Returns **[Object][1]** ## simd @@ -96,7 +82,7 @@ Versions of liborc prior to 0.4.25 are known to segfault under heavy load. ### Parameters -- `simd` **[Boolean][13]** (optional, default `false`) +- `simd` **[Boolean][2]** (optional, default `false`) ### Examples @@ -110,32 +96,10 @@ const simd = sharp.simd(true); // attempts to enable the use of SIMD, returning true if available ``` -Returns **[Boolean][13]** - -[1]: #cache - -[2]: #parameters - -[3]: #examples - -[4]: #concurrency - -[5]: #parameters-1 - -[6]: #examples-1 - -[7]: #counters - -[8]: #examples-2 - -[9]: #simd - -[10]: #parameters-2 - -[11]: #examples-3 +Returns **[Boolean][2]** -[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number diff --git a/package.json b/package.json index 1166e4343..182503783 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "test": "semistandard && cc && nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js && prebuild-ci", "coverage": "./test/coverage/report.sh", "test-leak": "./test/leak/leak.sh", - "docs": "for m in constructor input resize composite operation colour channel output utility; do documentation build --shallow --format=md lib/$m.js >docs/api-$m.md; done" + "docs": "for m in constructor input resize composite operation colour channel output utility; do documentation build --shallow --format=md --markdown-toc=false lib/$m.js >docs/api-$m.md; done" }, "main": "lib/index.js", "repository": {