Node.js GM rotate() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 // Include gm library const gm = require('gm'); // Import the image gm('gfg.png') // Invoke rotate function with background // color as #545651 and rotation angle as // 78 Degrees clockwise. .rotate("#545651", 78) // Process and Write the image .write("rotate1.png", function (err) { if (!err) console.log('done'); }); Output: Example 2: javascript // Include gm library const gm = require('gm'); // Import the image gm('gfg.png') // Set stroke color .stroke("#fe1232") // Set fill color .fill("#1200ff") // Draw Rectangle using drawRectangle function .drawRectangle(10, 2, 130, 30, 1, 2) //Invoke Sharpen Function with radius as 10 .sharpen(10, 4) // Invoke rotate function with background // color as #67f123 and rotation angle as // 45 Degrees clockwise. .rotate("#67f123", 45) // Process and Write the image .write("rotate2.png", function (err) { if (!err) console.log('done'); }); Output: Reference: http://www.graphicsmagick.org/GraphicsMagick.html#details-rotatehttps://www.npmjs.com/package/gm Comment More infoAdvertise with us Next Article Node.js GM raise() Function S sarthak_ishu11 Follow Improve Article Tags : Web Technologies Node.js Image-Processing NodeJS-function Node.js-GM +1 More Similar Reads Node.js GM raise() Function The raise() function is an inbuilt function in the GraphicsMagick library which is used to lighten or darken image edges. This will create a 3-D effect. The function returns the true value of success. Syntax: raise( width, height ) Parameters: This function accepts two parameters as mentioned above 1 min read Node.js GM write() Function The write() function is an inbuilt function in the GraphicsMagick library which is used to write an image to a file. If a file already exists, then it will be overwritten. The function returns the true value of success. Syntax: write( filename ) Parameters: This function accepts single parameters a 2 min read Node.js GM roll() Function The roll() function is an inbuilt function in the GraphicsMagick library which is used to roll an image vertically or horizontally. The function returns the true value on success. Syntax: roll( x, y ) Parameters: This function accepts two parameters as mentioned above and described below: x: This 1 min read Node.js GM stroke() Function 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 paramet 1 min read Node.js GM wave() Function The wave() function is an inbuilt function in the GraphicsMagick library which is used to alter an image along with a sine wave. The function returns the true value of success. Syntax: wave( amplitude, wavelength ) Parameters: This function accepts two parameters as mentioned above and described be 2 min read Node.js GM shade() Function The shade() function is an inbuilt function in the GraphicsMagick library which is used to shade the image using a distant light source. The function returns the true value of success. Syntax: shade( azimuthal angle, elevation angle ) Parameters: This function accepts two parameters as mentioned ab 1 min read Like