mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add extractChannel operation to extract a channel from an image (#497)
This commit is contained in:
committed by
Lovell Fuller
parent
f672f86b53
commit
83d8847f57
19
docs/api.md
19
docs/api.md
@@ -298,6 +298,25 @@ sharp(input)
|
||||
});
|
||||
```
|
||||
|
||||
#### extractChannel(channel)
|
||||
|
||||
Extract a channel from the image. The following channel names are equivalent:
|
||||
|
||||
* Red: `0, 'red'`
|
||||
* Green: `1, 'green'`
|
||||
* Blue: `2, 'blue'`
|
||||
|
||||
The result will be a single-channel grayscale image.
|
||||
|
||||
```javascript
|
||||
sharp(input)
|
||||
.extractChannel('green')
|
||||
.toFile('input_green.jpg',function(err, info) {
|
||||
// info.channels === 1
|
||||
// input_green.jpg contains the green channel of the input image
|
||||
});
|
||||
```
|
||||
|
||||
#### background(rgba)
|
||||
|
||||
Set the background for the `embed`, `flatten` and `extend` operations.
|
||||
|
||||
Reference in New Issue
Block a user