Reputation: 4672
I want to insert an image(img1) into another(img2) but before inserting, img1 must be resized based on img2 dimensions.
how can I achieve this with nodeJs gm ?
I'm using imageMagic.
Upvotes: 0
Views: 1066
Reputation: 3823
I just found solution, and answered my own question here: Resize and compose two or more images using gm in Nodejs, but here I post for your convenience:
gm()
.in('-geometry', '+0+0')
.in('./img/img1.png')
.in('-geometry', '300x300+100+200')
.in('./img/img2.png')
.flatten()
.write('resultGM.png', function (err) {
if (err) console.log(err);
});
Upvotes: 0
Reputation: 208077
I don't speak node
, but here is how you might do it at the command-line. I'll use these two images, both the same size at 200x100.
convert red.png \( gradient.png -resize 40% \) -gravity southeast -composite result.png
That gives this result:
To translate that into node
, you need to look at Eric's (@emcconville) answer here. I don't believe GraphicsMagick
supports the parentheses syntax, so I guess you will need to use the more sophisticated ImageMagick
.
Upvotes: 2