Nodejs | GM sharpen() Function
The sharpen() function is an inbuilt function in GraphicsMagick library which is used to sharpen the image. It uses a Gaussian operator of the given radius and standard deviation (sigma).
Syntax:
sharpen( radius, sd )
Parameters: This function accept two parameters as mentioned above and described below:
- radius: This parameter stores the radius value of the sharpness.
- sd: It is an optional parameter which stores the standard deviation of the image.
Return Value: This function returns Gmagick sharpen image.
Original Image:

Example 1:
// Include gm library var gm = require('gm'); // Import the image gm('1.png') // Invoke sharpen function with // radius as 10 ad standard // deviation as 2 .sharpen(10, 2) // Process and Write the image .write("1b.png", function (err) { if (!err) console.log('done'); }); |
chevron_right
filter_none
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 Sharpen Function with radius as 10 .sharpen(10) // Process and Write the image .write("1a.png", function (err) { if (!err) console.log('done'); }); |
chevron_right
filter_none
Output:

Reference:

