4

Currently I'm using this command:

montage IMG*.JPG -tile 3x1 -geometry 150x100+40+40 -background '#000000' triptych.jpg

And it produces an output like this (red lines added): too much space!

The problem (as indicated) is that my images have too much space between them, and that makes me sad.

I'm looking to create something that looks more like this, with the border equal all the way around:

equidistant excellence!

I checked the manpage and several online guides, but none of the options that I tried (-mode concatenate, changing the geometry to +40+20) did what I wanted.

How do I get the output that I want using imagemagick?

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290

2 Answers2

4

If you are just making a triptych, you may get on better with convert +append to lay out images in a row with spacers. So, if your images are 1.png, 2.png and 3.png:

convert -background black \
  1.png xc:black[10x] 2.png xc:black[10x] 3.png +append \
  -bordercolor black -border 10 result.png

enter image description here

The xc:black[10] are just the two spacers that you can set the width of explicitly. Then the three images with spacers are set in a horizontal row, using +append. Finally, at the end, I put a border around the whole lot with -border.

Or, showing how you have full control over all aspects:

convert -background black \
  1.png xc:black[15x] 2.png xc:black[5x] 3.png +append \
 -bordercolor black -border 40 result.png

enter image description here

As Wayne says in the comments, you can resize all the images to a uniform size too, while they are still separate before the -append, so you can do this to make sure no image is wider than 400 pixels.

convert -background black \
  1.png xc:black[10x] 2.png xc:black[10x] 3.png -resize 400x\> +append \
  -bordercolor black -border 10 result.png

If you want even more control, you can individually resize the images like this:

convert -background black               \
  \( 1.png -resize WxH \) xc:black[10x] \
  \( 2.png -resize AxB \) xc:black[10x] \
  \( 3.png -resize MxN \) +append       \
  -bordercolor black -border 10 result.png

If you want a vertical triptych, use -append in place of +append and set the spacer height with xc:black[x10] rather than xc:black[10x].

convert -background black \
  1.png xc:black[x10] 2.png xc:black[x10] 3.png -append \
  -bordercolor black -border 10 result.png

enter image description here

Keywords: triptych, diptych, montage, photographer, photography, photo, spacing, spacer, padding

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • this works *perfectly* (and now when searching Google for "create triptych imagemagick" should show up in the results ;) – Wayne Werner May 16 '16 at 12:49
  • note, that if you want to ensure that larger images are downsized you can add the `-resize \>` flag before `-append`. If you want to make sure no image is wider than 400px, say, you'd use `-resize 400x\>` (and `x400\>` if you want them no taller than 400px) – Wayne Werner May 16 '16 at 13:41
1

Another method is doing it in two steps.

montage img-*.png -background '#000' -geometry +20+20 step-1.png # step 1
convert step-1.png -bordercolor '#000' -border 20 step-2.png # step 2

enter image description here

With step 1, you got the green spacing. And with step 2, you got the red spacing

HumeNi
  • 7,788
  • 1
  • 11
  • 9