3.8 KiB
tint
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
Examples
const output = await sharp(input)
.tint({ r: 255, g: 240, b: 16 })
.toBuffer();
- Throws Error Invalid parameter
Returns Sharp
greyscale
Convert to 8-bit greyscale; 256 shades of grey.
This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use gamma()
with greyscale()
for the best results.
By default the output image will be web-friendly sRGB and contain three (identical) color channels.
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
greyscale
Boolean (optional, defaulttrue
)
Examples
const output = await sharp(input).greyscale().toBuffer();
Returns Sharp
grayscale
Alternative spelling of greyscale
.
Parameters
grayscale
Boolean (optional, defaulttrue
)
Returns Sharp
pipelineColourspace
Set the pipeline colourspace.
The input image will be converted to the provided colourspace at the start of the pipeline. All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
This feature is experimental and has not yet been fully-tested with all operations.
Parameters
Examples
// Run pipeline in 16 bits per channel RGB while converting final result to 8 bits per channel sRGB.
await sharp(input)
.pipelineColourspace('rgb16')
.toColourspace('srgb')
.toFile('16bpc-pipeline-to-8bpc-output.png')
- Throws Error Invalid parameters
Returns Sharp
Meta
- since: 0.29.0
pipelineColorspace
Alternative spelling of pipelineColourspace
.
Parameters
colorspace
string? pipeline colorspace.
- Throws Error Invalid parameters
Returns Sharp
toColourspace
Set the output colourspace. By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
Parameters
Examples
// Output 16 bits per pixel RGB
await sharp(input)
.toColourspace('rgb16')
.toFile('16-bpp.png')
- Throws Error Invalid parameters
Returns Sharp
toColorspace
Alternative spelling of toColourspace
.
Parameters
colorspace
string? output colorspace.
- Throws Error Invalid parameters
Returns Sharp