Node.js GM chop() Function
Last Updated :
31 Mar, 2023
The chop() function is an inbuilt function in the GraphicsMagick library which is used to remove pixels from the interior of an image. The function returns the true value of success.
Syntax:
chop( width, height, x, y )
Parameters: This function accepts four parameters as mentioned above and described below:
- width: This parameter is used to specify the width from which the image is to be chopped.
- height: This parameter is used to specify the height from which the image is to be chopped.
- x: This parameter is used to specify the x-coordinates from the width.
- y: This parameter is used to specify the y-coordinates from height.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.borderColor( 'Green' )
.border(10, 30)
.chop(100, 30, 40, 50)
.write( "chop1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm(600, 300, 'white' )
.stroke( "green" , 3)
.font( "Helvetica.ttf" , 60)
.drawText(100, 280, "GeeksforGeeks!" )
.borderColor( "Green" )
.border(62, 32)
.chop(300, 180, 10, 50)
.write( "chop2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...