Node.js GM charcoal() Function
The charcoal() function is an inbuilt function in the GraphicsMagick library which is used to add a charcoal filter to the image. The function returns the true value of success.
Syntax:
charcoal( factor )
Parameters: This function accepts a single parameter which is mentioned above and described below:
- factor: This parameter stores the value of the charcoal factor which is to be applied to the image.
Return Value: This function returns the Gmagick charcoal image.
Original Image:
Example 1:
javascript
// Include gm library const gm = require( 'gm' ); // Import the image gm( '1.png' ) // Invoke Charcoal function // with charcoal factor as 12 .charcoal(4) // Process and Write the image .write( "charcoal1.png" , function (err) { if (!err) console.log( 'done' ); }) |
Output:
Example 2:
javascript
// Include gm library const gm = require( 'gm' ); // Import the image gm( '1.png' ) // Set stroke color .stroke( "#fe1232" ) // Set fill color .fill( "#1200ff" ) / Draw Rectangle using drawRectangle function .drawRectangle(10, 2, 130, 30, 1, 2) //Invoke Charcoal function as factor 3 .charcoal(3) // Process and Write the image .write( "charcoal2.png" , function (err) { if (!err) console.log( 'done' ); }) |
Output:
Reference:
Please Login to comment...