Node.js GM channel() Function
Last Updated :
30 Mar, 2023
The channel() function is an inbuilt function in the GraphicsMagick library which is used to extract a particular channel from the image.
Syntax:
channel( channelType )
Parameters: This function accepts a single parameter channelType which holds the type of channel name. The types of channels are Red, Green, Blue, Opacity, Matte, Cyan, Magenta, Yellow, Black, or Gray.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.borderColor( 'Green' )
.border(10, 30)
.channel( 'All' )
.write( "channel-all1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm(600, 300, 'white' )
.stroke( "green" , 3)
.font( "Helvetica.ttf" , 60)
.drawText(100, 280, "GeeksforGeeks!" )
.borderColor( "Green" )
.border(62, 32)
.channel( 'Green' )
.write( "channel-green.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...