mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add ensureAlpha op, adds alpha channel if missing #1153
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user