36.10 Image Combine


To combine two png images into one image file we can use +append (for side-by-side) and -append (on top of each other).

convert img1.png img2.png +append result.png

For a resulting pdf file:

convert img1.png img2.png +append result.pdf

Append the images top to bottom, with space at top:

convert img1.png img2.png -gravity south -append result.pdf

As a more complex example we take two images from the internet, generate an arrow image and then combine all three into one image with an arrow in between. Various resizing and border placement is done to improve the aesthetics.

$ wget -O img1.jpg \

$ wget -O img2.jpg \

$ arrow_head="l -15,-5  +5,+5  -5,+5  +15,-5 z"
$ convert -size 100x30 xc: -draw 'stroke skyblue fill skyblue rectangle 30,14 70,16' \
          -draw "stroke skyblue fill skyblue path 'M 70,15  $arrow_head' " \
      -resize 400% arrow.png

$ convert img1.jpg arrow.png img2.jpg -gravity center +append \
          -resize 30% -bordercolor white -border 10x10 result.png
$ display result.png

The images used here come from https://www.goodfreephotos.com and is under the license.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0