VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-gm-crop-function/

⇱ Node.js GM crop() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js GM crop() Function

Last Updated : 28 Apr, 2025

The crop() function is an inbuilt function in the GraphicsMagick library which is used to remove the unwanted areas of the image by specifying the coordinates. The function returns the true value on success. 

Syntax:

crop(width, height, x, y, percentage)

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

  • width: This parameter is used to specify the width from which the image is to be cropped.
  • height: This parameter is used to specify the height from which the image is to be cropped.
  • x: This parameter is used to specify the width by which the image is to be cropped.
  • y: This parameter is used to specify the width by which the image is to be cropped.
  • percentage: This parameter is used to specify the boolean value if true then all the previously mentioned values are considered to be percentages else in pixels.

Return Value: This function returns the GraphicsMagick object. 

Example 1: 

Output:

 👁 Image
 

Example 2: 

Output:

 👁 Image
 

Reference:

Comment

Explore