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:
Image



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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


Output:
Image

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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


Output:
Image

Reference:




My Personal Notes arrow_drop_up

Image
Check out this Author's contributed articles.

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.