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 on success.
Syntax:
charcoal( factor )
Parameters: This function accepts single parameter which is mentioned above and described below:
- factor: This parameter stores the value of the charcoal factor which is to be apply on the image.
Return Value: This function returns Gmagick charcoal image.
Original Image:

Example 1:
// Include gm library var 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:
// Include gm library var 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:
Recommended Posts:
- Pgmagick charcoal() method - Python
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs | GM gamma() Function
- Nodejs | GM gaussian() Function
- Nodejs | GM emboss() Function
- Nodejs | GM paint() Function
- Nodejs | GM shave() Function
- Nodejs | GM whitePoint() Function
- Nodejs | GM solarize() Function
- Nodejs | GM spread() Function
- Nodejs | GM minify() Function
- Nodejs | GM magnify() Function
- Nodejs | GM blur() Function
- Nodejs | GM write() Function
- Nodejs | GM bordercolor() Function
- Nodejs | GM flop() Function
- Nodejs | GM whiteThreshold() Function
- Nodejs | GM flip() Function
- Nodejs | GM threshold() Function
- Nodejs | GM operator() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

