Node.js GM paint() Function

The paint() function is an inbuilt function in the GraphicsMagick library which is used to simulate an oil painting. The function returns the true value of success.

Syntax:

paint( radius )

Parameters: This function accepts a single parameter as mentioned above and described below:

  • radius: This parameter is used to specify the radius of the paint.

Return Value: This function returns the GraphicsMagick object. 

Example 1: 

javascript




// Include gm library
const gm = require('gm');
 
// Import the image
gm('1.png')
 
// Invoke ordered Dither on
// Green Channel with 50 x 60
.paint(2)
 
// Process and Write the image
.write("paint1.png", function (err) {
    if (!err) console.log('done');
});


Output:

  

Example 2: 

javascript




// Include gm library
const gm = require('gm');
 
//Import the image
gm(600, 300, 'white')
 
// set the color for the stroke
.stroke("green", 3)
 
// Set the font
.font("Helvetica.ttf", 60)
 
// Call to drawText Function
.drawText(100, 280, "w3wiki!")
 
// Invoke paint function
.paint(1.2)
 
// Process and write the image
.write("paint2.png", function (err) {
    if (!err) console.log('done');
});


Output:

 

 Reference: 

  • http://www.graphicsmagick.org/GraphicsMagick.html#details-paint
  • https://www.npmjs.com/package/gm


Contact Us