Node.js GM negative() Function
The negative() function is an inbuilt function in the GraphicsMagick library which is used to replace every pixel with its complementary color. The function returns the true value on success.
Syntax:
negative()
Parameters: This function does not accept any parameter.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' ).negative()
.write( "negative1.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)
.negative()
.write( "negative2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 3:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.composite( 'operator-noise-multiplicative1.png' )
.geometry( '+10+50' )
.compose( 'plus' )
.composite( 'randomThreshold1.png' )
.geometry( '+20+70' )
.compose( 'plus' )
.negative()
.write( 'negative3.png' , function (err) {
if (!err) console.log( "Written composite image." );
});
|
Output:
Reference:
Last Updated :
31 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...