Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go

Combine Images

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

$ wget -O img1.jpg \
  https://www.goodfreephotos.com/cache/australia/south-australia/adelaide/\
adelaide-northern-terrace-in-1839-southern-australia.jpg

$ wget -O img2.jpg \
  https://www.goodfreephotos.com/albums/australia/south-australia/adelaide/\
north-terrace-of-adelaide-in-1841-in-southern-australia.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

Figure 36.5: Using imagemagick to append multiple images, including an imagemagick generated arrow, into a single image.
Image imagemagick_append

The images used here come from https://www.goodfreephotos.comand is under the CC0 / Public Domain license.


Copyright © 1995-2020 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware and the author of open source software including Rattle and wajig.
Also the author of Data Mining with Rattle and Essentials of Data Science.