Open In App

Node.js GM shave() Function

The shave() function is an inbuilt function in the GraphicsMagick library which is used to shave the image pixels from the edges which specifies 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. 

Syntax:



shave(width, height, percentage)

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

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



Original Image:

  

Program: 




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

Output:

  

Reference:

Article Tags :