Node.js GM median() Function
Last Updated :
31 Mar, 2023
The median() function is an inbuilt function in the GraphicsMagick library which is used to apply a median filter to the image. The function returns the true value on success. Note: This function does not work after the composite() function.
Syntax:
median(radius)
Parameters: This function accepts a single parameter radius which is the radius of the pixel.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.median(2)
.write( "median1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm(600, 300, 'white' )
.stroke( "green" , 3)
.font( "Helvetica.ttf" , 60)
.drawText(100, 280, "GeeksforGeeks!" )
.borderColor( "Green" )
.border(62, 32)
.median(5)
.write( "median2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...