ImageMagick - Combine and center multiple images

I am trying to add several PNG files that have different sizes to one combined image.

I want the individual β€œlayers” to be centered.

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

.

Simple:

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

leads to:

.

... and I managed to center everything by manually specifying the offsets ( '-page +X+Y' ), but I was wondering if there was an automatic way to achieve this.

+6
source share
2 answers

You can avoid the temporary file by linking b.png to a.png and then c.png on top of this:

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

enter image description here

+7
source

The best, but still not the best solution because of the temporary image:

 composite -gravity center b.png a.png temp.png \ && \ composite -gravity center c.png temp.png composite.png 
+6
source

Source: https://habr.com/ru/post/899334/


All Articles