Add ensureAlpha op, adds alpha channel if missing #1153

This commit is contained in:
Lovell Fuller
2019-01-05 21:12:33 +00:00
parent 8e70579e47
commit 4c01a099ea
9 changed files with 84 additions and 0 deletions

View File

@@ -16,6 +16,22 @@ sharp('rgba.png')
Returns **Sharp**
## ensureAlpha
Ensure alpha channel, if missing. The added alpha channel will be fully opaque. This is a no-op if the image already has an alpha channel.
### Examples
```javascript
sharp('rgb.jpg')
.ensureAlpha()
.toFile('rgba.png', function(err, info) {
// rgba.png is a 4 channel image with a fully opaque alpha channel
});
```
Returns **Sharp**
## extractChannel
Extract a single channel from a multi-channel image.

View File

@@ -9,6 +9,9 @@ Requires libvips v8.7.0.
* Ensure shortest edge is at least one pixel after resizing.
[#1003](https://github.com/lovell/sharp/issues/1003)
* Add `ensureAlpha` operation to add an alpha channel, if missing.
[#1153](https://github.com/lovell/sharp/issues/1153)
* Expose `pages` and `pageHeight` metadata for multi-page input images.
[#1205](https://github.com/lovell/sharp/issues/1205)