From 24d9e53c3f53a5b2b6e089b5727a8b058984604f Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Tue, 26 Jan 2021 15:03:43 +0000 Subject: [PATCH] Docs: add example of 16-bit RGB output #2528 --- docs/api-colour.md | 8 ++++++++ lib/colour.js | 7 +++++++ 2 files changed, 15 insertions(+) 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