Skip to content

Commit

Permalink
Docs: add example of 16-bit RGB output #2528
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Jan 26, 2021
1 parent 573ed5f commit 24d9e53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/api-colour.md
Expand Up @@ -48,6 +48,14 @@ By default output image will be web-friendly sRGB, with additional channels inte

- `colourspace` **[string][1]?** output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][6]

### Examples

```javascript
// Output 16 bits per pixel RGB
await sharp(input)
.toColourspace('rgb16')
.toFile('16-bpp.png')
```

- Throws **[Error][4]** Invalid parameters

Expand Down
7 changes: 7 additions & 0 deletions lib/colour.js
Expand Up @@ -57,6 +57,13 @@ function grayscale (grayscale) {
/**
* Set the output colourspace.
* By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
*
* @example
* // Output 16 bits per pixel RGB
* await sharp(input)
* .toColourspace('rgb16')
* .toFile('16-bpp.png')
*
* @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/master/libvips/iofuncs/enumtypes.c#L568)
* @returns {Sharp}
* @throws {Error} Invalid parameters
Expand Down

0 comments on commit 24d9e53

Please sign in to comment.