Node.js GM trim() Function
Last Updated :
30 Mar, 2023
The trim() function is an inbuilt function in the GraphicsMagick library which is used to remove edges that are exactly the same color as the corner pixels. The function returns the true value of success.
Syntax:
trim()
Parameters: This function does not accept any parameters.
Return Value: This function returns the GraphicsMagick object with a trimmed image added.
Original Image:
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.trim()
.write( "trim1.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Example 2:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.stroke( "#fe1232" )
.fill( "#1200ff" )
.drawRectangle(10, 2, 130, 30, 1, 2)
.wave(20, 30)
.trim()
.write( "trim2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...