Node.js GM scale() Function
Last Updated :
31 Mar, 2023
The crop() function is an inbuilt function in the GraphicsMagick library that allows you to resize images. The function returns the true value on success.
Syntax:
crop(width, height)
Parameters: This function accepts two parameters as mentioned above and described below:
- width: This parameter is used to specify the width from which the image is to be scaled.
- height: This parameter is used to specify the height from which the image is to be scaled.
Return Value: This function returns the GraphicsMagick object.
Example 1:
javascript
const gm = require( 'gm' );
gm( '1.png' )
.scale(130, 230)
.write( "scale1.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)
.scale(300, 200)
.write( "scale2.png" , function (err) {
if (!err) console.log( 'done' );
});
|
Output:
Reference:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...