mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add removeAlpha op, removes alpha channel if any #1248
This commit is contained in:
@@ -12,6 +12,23 @@ const bool = {
|
||||
eor: 'eor'
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.
|
||||
*
|
||||
* @example
|
||||
* sharp('rgba.png')
|
||||
* .removeAlpha()
|
||||
* .toFile('rgb.png', function(err, info) {
|
||||
* // rgb.png is a 3 channel image without an alpha channel
|
||||
* });
|
||||
*
|
||||
* @returns {Sharp}
|
||||
*/
|
||||
function removeAlpha () {
|
||||
this.options.removeAlpha = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a single channel from a multi-channel image.
|
||||
*
|
||||
@@ -102,6 +119,7 @@ function bandbool (boolOp) {
|
||||
module.exports = function (Sharp) {
|
||||
// Public instance functions
|
||||
[
|
||||
removeAlpha,
|
||||
extractChannel,
|
||||
joinChannel,
|
||||
bandbool
|
||||
|
||||
Reference in New Issue
Block a user