Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick - Merge and center multiple images

I am trying to append multiple PNG files, which are of different dimensions, into a single combined image.

I want individual 'layers' to be centered.

This is what I am trying to achieve in pictorial form:

.

A simple:

convert a.png b.png c.png -flatten combined.png

results in:

.

...and I was able to center everything by manually specifying offsets ('-page +X+Y') but I was wondering if there is an automatic way of achieving this.

like image 776
Hamza Avatar asked Oct 14 '11 21:10

Hamza


1 Answers

You can avoid the temporary file by compositing b.png onto a.png and then c.png on top of that like this:

convert -gravity center a.png b.png -composite c.png -composite result.png

enter image description here

like image 138
Mark Setchell Avatar answered Nov 25 '22 19:11

Mark Setchell