diff --git a/docs/api-colour.md b/docs/api-colour.md index bf9237eb..8dca338c 100644 --- a/docs/api-colour.md +++ b/docs/api-colour.md @@ -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 diff --git a/lib/colour.js b/lib/colour.js index d2151613..c4516c5a 100644 --- a/lib/colour.js +++ b/lib/colour.js @@ -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