How to add labels to columns using ImageMagick montage

218 views Asked by At

I need to create a collage of 12 JPEG images using ImageMagick montage command:

montage image{1..12}.jpg -tile 3x4 -geometry +10+10 output.jpg

The command above creates a collage of 4 rows and 3 columns.

My aim is to add 3 labels (a), (b), (c) to the columns.

The result should look like:

(a)   (b)   (c)

img1   img2  img3
img4   img5  img6
img7   img8  img9
img10  img11 img12

I have tried using the -label flag but I can't get it to work.

My question is how can I add the labels as shown above?


I have the following version of ImageMagick:

Version: ImageMagick 7.1.0-13 Q16-HDRI x86_64 2021-10-29 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5) 
Delegates (built-in): bzlib fontconfig freetype jbig jng jp2 jpeg lcms lzma pangocairo png tiff webp x xml zip zlib
Compiler: gcc (8.4)
1

There are 1 answers

0
fmw42 On BEST ANSWER

You can do that in Imagemagick by appending a label above the first 3 images and piping all images to montage. I use -smush to add space rather than -append.

convert \
\( -pointsize 32 label:"(a)" lena.jpg -gravity center -smush 20 -set label "" \) \
\( -pointsize 32 label:"(b)" mandril3.jpg -gravity center -smush 20 -set label "" \) \
\( -pointsize 32 label:"(c)" zelda1.jpg -gravity center -smush 20 -set label "" \) \
zelda1.jpg lena.jpg mandril3.jpg miff:- |\
montage - -tile 3x2 -geometry +10+10 result.jpg

enter image description here