Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick: Layering Images with convert -composite with gravity center

enter image description here

background

http://i.stack.imgur.com/wA2EL.png

overlay

composite -gravity center overlay.png  background.jpg  result1.jpg

http://i.stack.imgur.com/XgdA2.jpg

result1.jpg

convert -composite background.jpg overlay.png -gravity center result2.jpg

result2.jpg

convert -composite background.jpg -gravity center tool_marker.png  result3.jpg

result3.jpg

How can I achieve the results from result1 while using convert as the executable rather than composite?

Thanks!

like image 510
Piotr Tomasik Avatar asked Jan 27 '12 10:01

Piotr Tomasik


1 Answers

You can start by using the operators in the right order. That is set the 'settings' first. "Composite" command is 'read all settings then apply ONE operation, type of command (traditional UNIX) "Convert" is a 'do options as you see them', with MULTIPLE operations possible. (script-like command)

convert  background.jpg  tool_marker.png -geometry +50+50 -composite result4.jpg

Note the +50+50 is the location of the top-left corner of the 'tool_marker.png" image. You will need to subtract the 'pin-point' location in that image to get it to pin point in the right location.

Gravity Center (if given BEFORE the -composite operation that uses it), aligns the center of BOTH images.

convert background.jpg tool_marker.png -gravity center -composite result4.jpg
like image 135
Piotr Tomasik Avatar answered Nov 08 '22 16:11

Piotr Tomasik