Node.js GM rotate() Function
The rotate() function is an inbuilt function in the GraphicsMagick library which is used to rotate the image by the specified angle. The function returns the true value of success.
Syntax:
rotate( angle, color )
Parameters: This function accepts two parameters as mentioned above and described below:
- angle: This parameter stores the value of the angle.
- color: This parameter stores the value of the color as a string which is to be set as the background color.
Return Value: This function returns the GraphicsMagick object with an image added.
Original Image:
Example 1:
javascript
const gm = require( 'gm' );
gm( 'gfg.png' )
.rotate( "#545651" , 78)
.write( "rotate1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm( 'gfg.png' )
.stroke( "#fe1232" )
.fill( "#1200ff" )
.drawRectangle(10, 2, 130, 30, 1, 2)
.sharpen(10, 4)
.rotate( "#67f123" , 45)
.write( "rotate2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Last Updated :
30 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...