Skip to content
Related Articles

Related Articles

Improve Article
Nodejs | GM shave() Function
  • Last Updated : 15 Apr, 2020

The shave() function is an inbuilt function in the GraphicsMagick library which is used to shave the image pixels from the edges which specify the width of the region to be removed from both sides of the image and the height of the regions to be removed from top and bottom.


shave(width, height, percentage)

Parameters: This function accepts three parameters as mentioned above and described below:

  • width: This parameter stores the value of the width by which the image is to be shaved.
  • height: This parameter stores the value of the height by which the image is to be shaved.
  • percentage: This is an optional boolean parameter which stores the percentage if set true otherwise pixels.

Return Value: This function returns Gmagick object with image added.

Original Image:


// Include gm library
var gm = require('gm');
// Import the image
// Invoke shave function
.shave(30, 40, true)
// Process and Write the image
.write("shave1.png", function (err) {
  if (!err) console.log('done');



My Personal Notes arrow_drop_up
Recommended Articles
Page :