Skip to content

Commit

Permalink
Documentation refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Jun 20, 2018
1 parent 94607b5 commit 0d9590a
Show file tree
Hide file tree
Showing 11 changed files with 686 additions and 443 deletions.
59 changes: 37 additions & 22 deletions docs/api-channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
### Table of Contents

- [extractChannel][1]
- [joinChannel][2]
- [bandbool][3]
- [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**
### Parameters

- `channel` **([Number][4] \| [String][5])** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively.
- `channel` **([Number][9] \| [String][10])** zero-indexed band number to extract, or `red`, `green` or `blue` as alternative to `0`, `1` or `2` respectively.

**Examples**
### Examples

```javascript
sharp(input)
Expand All @@ -25,7 +30,7 @@ sharp(input)
});
```

- Throws **[Error][6]** Invalid channel
- Throws **[Error][11]** Invalid channel

Returns **Sharp**

Expand All @@ -42,25 +47,25 @@ Channel ordering follows vips convention:
Buffers may be any of the image formats supported by sharp: JPEG, PNG, WebP, GIF, SVG, TIFF or raw pixel image data.
For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.

**Parameters**
### Parameters

- `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.
- `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.


- Throws **[Error][6]** Invalid parameters
- Throws **[Error][11]** Invalid parameters

Returns **Sharp**

## bandbool

Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.

**Parameters**
### Parameters

- `boolOp` **[String][5]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
- `boolOp` **[String][10]** one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.

**Examples**
### Examples

```javascript
sharp('3-channel-rgb-input.png')
Expand All @@ -72,24 +77,34 @@ sharp('3-channel-rgb-input.png')
});
```

- Throws **[Error][6]** Invalid parameters
- Throws **[Error][11]** Invalid parameters

Returns **Sharp**

[1]: #extractchannel

[2]: #joinchannel
[2]: #parameters

[3]: #bandbool
[3]: #examples

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[4]: #joinchannel

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[5]: #parameters-1

[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
[6]: #bandbool

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[7]: #parameters-2

[8]: https://nodejs.org/api/buffer.html
[8]: #examples-1

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[13]: https://nodejs.org/api/buffer.html

[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
82 changes: 50 additions & 32 deletions docs/api-colour.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
### Table of Contents

- [background][1]
- [tint][2]
- [greyscale][3]
- [grayscale][4]
- [toColourspace][5]
- [toColorspace][6]
- [Parameters][2]
- [tint][3]
- [Parameters][4]
- [greyscale][5]
- [Parameters][6]
- [grayscale][7]
- [Parameters][8]
- [toColourspace][9]
- [Parameters][10]
- [toColorspace][11]
- [Parameters][12]

## background

Expand All @@ -18,12 +24,12 @@ Delegates to the _color_ module, which can throw an Error
but is liberal in what it accepts, clipping values to sensible min/max.
The alpha value is a float between `0` (transparent) and `1` (opaque).

**Parameters**
### Parameters

- `rgba` **([String][7] \| [Object][8])** parsed by the [color][9] module to extract values for red, green, blue and alpha.
- `rgba` **([String][13] \| [Object][14])** parsed by the [color][15] module to extract values for red, green, blue and alpha.


- Throws **[Error][10]** Invalid parameter
- Throws **[Error][16]** Invalid parameter

Returns **Sharp**

Expand All @@ -32,12 +38,12 @@ Returns **Sharp**
Tint the image using the provided chroma while preserving the image luminance.
An alpha channel may be present and will be unchanged by the operation.

**Parameters**
### Parameters

- `rgb` **([String][7] \| [Object][8])** parsed by the [color][9] module to extract chroma values.
- `rgb` **([String][13] \| [Object][14])** parsed by the [color][15] module to extract chroma values.


- Throws **[Error][10]** Invalid parameter
- Throws **[Error][16]** Invalid parameter

Returns **Sharp**

Expand All @@ -50,19 +56,19 @@ This may be overridden by other sharp operations such as `toColourspace('b-w')`,
which will produce an output image containing one color channel.
An alpha channel may be present, and will be unchanged by the operation.

**Parameters**
### Parameters

- `greyscale` **[Boolean][11]** (optional, default `true`)
- `greyscale` **[Boolean][17]** (optional, default `true`)

Returns **Sharp**

## grayscale

Alternative spelling of `greyscale`.

**Parameters**
### Parameters

- `grayscale` **[Boolean][11]** (optional, default `true`)
- `grayscale` **[Boolean][17]** (optional, default `true`)

Returns **Sharp**

Expand All @@ -71,48 +77,60 @@ Returns **Sharp**
Set the output colourspace.
By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.

**Parameters**
### Parameters

- `colourspace` **[String][7]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][12]
- `colourspace` **[String][13]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][18]


- Throws **[Error][10]** Invalid parameters
- Throws **[Error][16]** Invalid parameters

Returns **Sharp**

## toColorspace

Alternative spelling of `toColourspace`.

**Parameters**
### Parameters

- `colorspace` **[String][7]?** output colorspace.
- `colorspace` **[String][13]?** output colorspace.


- Throws **[Error][10]** Invalid parameters
- Throws **[Error][16]** Invalid parameters

Returns **Sharp**

[1]: #background

[2]: #tint
[2]: #parameters

[3]: #greyscale
[3]: #tint

[4]: #grayscale
[4]: #parameters-1

[5]: #tocolourspace
[5]: #greyscale

[6]: #tocolorspace
[6]: #parameters-2

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[7]: #grayscale

[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[8]: #parameters-3

[9]: https://www.npmjs.org/package/color
[9]: #tocolourspace

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
[10]: #parameters-4

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[11]: #tocolorspace

[12]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568
[12]: #parameters-5

[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[15]: https://www.npmjs.org/package/color

[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[18]: https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568
64 changes: 35 additions & 29 deletions docs/api-composite.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
### Table of Contents

- [overlayWith][1]
- [Parameters][2]
- [Examples][3]

## overlayWith

Expand All @@ -13,27 +15,27 @@ If both `top` and `left` options are provided, they take precedence over `gravit

If the overlay image contains an alpha channel then composition with premultiplication will occur.

**Parameters**

- `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**
### 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.

### Examples

```javascript
sharp('input.png')
Expand All @@ -54,22 +56,26 @@ sharp('input.png')
});
```

- Throws **[Error][8]** Invalid parameters
- Throws **[Error][10]** Invalid parameters

Returns **Sharp**

[1]: #overlaywith

[2]: https://nodejs.org/api/buffer.html
[2]: #parameters

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[3]: #examples

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[4]: https://nodejs.org/api/buffer.html

[5]: 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/Boolean
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[7]: https://www.npmjs.org/package/color
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[9]: https://www.npmjs.org/package/color

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
Loading

0 comments on commit 0d9590a

Please sign in to comment.