Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick composite resizes image before composing

I'm using ImageMagick's composite command to compose one smaller image over larger one. The resulting image should be of size of the background image (the larger one). Additionally I want the smaller one to be always of the same size.

Currently I have such a simple invocation:

composite -gravity SouthWest watermark.png photo.jpg photo.jpg

The problem is that I get different sizes of watermark for different photos and I don't know how to set it to be fixed size. I tried -resize, -geometry and -size options but all of them change size of resulting image and not the watermark.

like image 378
Lukasz Korzybski Avatar asked Feb 25 '23 16:02

Lukasz Korzybski


1 Answers

I had a similar problem and tried all sorts of different options with the composite command to try to get it to work. Eventually I had to switch to using the convert command and was able to get it to resize with gravity using:

convert photo.jpg -gravity SouthWest -draw "image Over 0,0,200,200 watermark.png" photo.jpg

The numeric parameters for -draw are left,top,width,height. See http://www.imagemagick.org/script/command-line-options.php?#draw. So this solution no longer uses the composite command but hopefully gives you what you want.

like image 194
Jeff Steil Avatar answered Mar 04 '23 08:03

Jeff Steil