Skip to content
Related Articles

Related Articles

Nodejs | GM orderedDither() Function
  • Last Updated : 16 Mar, 2020

The orderedDither() function is an inbuilt function in the GraphicsMagick library which is used to ordered dither the image. The ordered dither method is used to reduce channel or channeltype argument into binary. The values of channeltype are All, Intensity, Red, Green, Blue, Cyan, Magenta, Yellow, Black, and Opacity. The function returns the true value on 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:






// Include gm library
var gm = require('gm');
  
// Import the image
gm('1.png')
  
// Invoke ordered Dither on Green
// Channel with 50 x 60
.orderedDither('Green', '50x60')
  
// Process and Write the image
.write("orderedDither1.png", function (err) {
  if (!err) console.log('done');
});

Output:

Example 2:




// Include gm library
var gm = require('gm');
  
//Import the image
gm(600, 300, 'white')
  
// set the color for the stroke
.stroke("green", 3)
  
// Set the font 
.font("Helvetica.ttf", 60)
  
//Call to drawText Function
.drawText(100, 280, "GeeksforGeeks!")
  
// Invoke ordered Dither with 'All'
// Channel with 110 x 110
.orderedDither('All', '110x110')
  
// Process and write the image 
.write("ordereddither2.png", function (err) {
  if (!err) console.log('done');
});

Output:

Reference:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :