Open In App

Node.js GM paint() Function

Last Updated : 31 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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, "GeeksforGeeks!")
 
// Invoke paint function
.paint(1.2)
 
// Process and write the image
.write("paint2.png", function (err) {
    if (!err) console.log('done');
});


Output:

 

 Reference: 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads