Node.js GM stroke() Function
Last Updated :
30 Mar, 2023
The stroke() function is an inbuilt function in the GraphicsMagick library which is used to set the color and width of the stroke used to draw object outlines.
Syntax:
stroke( color, width )
Parameters: This function accepts two parameters as mentioned above and described below:
- color: This parameter stores the color of the stroke.
- width: This is an optional parameter that stores the width of the object.
Return Value: This function returns the GraphicsMagick object with the image added.
Original Image:
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.stroke( "#fe1232" , 5)
.fill( "#56f864" )
.drawCircle(120, 50, 100, 60).stroke()
.write( "1a.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Original Image:
Example 2:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.stroke( "#fe1232" )
.fill( "#1200ff" )
.drawRectangle(10, 2, 130, 30, 1, 2)
.write( "1a.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...