Node.js GM orderedDither() Function
Last Updated :
30 Mar, 2023
The orderedDither() function is an inbuilt function in the GraphicsMagick library which is used to order dither the image. The ordered dither method is used to reduce channel or channel type argument into binary. The values of channel type are All, Intensity, Red, Green, Blue, Cyan, Magenta, Yellow, Black, and Opacity. The function returns the true value of success.
Syntax:
orderedDither( ChannelType, NxN )
Parameters: This function accepts two parameters as mentioned above and described below:
- ChannelType: This parameter is used to specify the Channel Type as All, Intensity, Red, Green, Blue, Cyan, Magenta, Yellow, Black, and Opacity.
- NxN: This parameter is used to specify the minimum and maximum level of the intensity.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.orderedDither( 'Green' , '50x60' )
.write( "orderedDither1.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!" )
.orderedDither( 'All' , '110x110' )
.write( "ordereddither2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...