Quick n’ easy mosaics with ImageMagick

15.05.2018 @ Tutorials(Command line)

Cre­at­ing a mosa­ic of sev­er­al images is bor­ing grunt work. Luck­ly it can be auto­mat­ed! ImageMag­ick can eas­i­ly cre­ate a mosa­ic of many images with just one com­mand: mon­tage

You can run mon­tage with a list of images you want to put in a mosa­ic like this:

montage image_1.jpg image_2.jpg image_3.jpg image_4.jpg mosaic.jpg

Note that we need a final para­me­ter for the out­put filepath. The real pow­er, though comes from using shell wild­cards like this:

montage *.jpg mosaic.jpg

You can also tell mon­tage to fit the images in a spe­cif­ic size using the geom­e­try para­me­ter. Notice the size defines the cell size and images will fit inside it, keep­ing their ratios while small­er images will not be resized. Geom­e­try also takes a val­ue for the spac­ing of tiles in x and y (+x+y). Let’s say we want to our images to fit inside 500x500px with a 2px gap between them, this is the comand we could use:

montage -geometry 500x500+2+2 *.jpg mosaic.jpg

It’s also pos­si­ble to give it a cer­tain amout of tiles with the tile com­mand

montage -tile 4x1 *.jpg mosaic.jpg

What about crop­ping images instead of resiz­ing? The crop para­me­ter takes a size in pix­els (width x height) or a per­cent­age, along with a posi­tion (+x+y).

montage -crop 1000x1000+0+0 *.jpg mosaic.jpg
montage -crop 1000x1000+500+0 *.jpg mosaic.jpg

Final­ly we can get rid of the gaps with -mode con­cate­nate. Watch out though, if one of the images is small­er and you’re not crop­ping it will leave a small gap.

montage -mode concatenate *.jpg mosaic.jpg
montage -mode concatenate -crop 1000x1000+500+0 *.jpg mosaic.jpg

You can also add shad­ows, bor­ders, labels and plen­ty of oth­er cool tricks! Check out the mon­tage doc­u­men­ta­tion for more info.

The awe­some food pho­tos come from Pixabay.com.

All the posts you can read

No comments yet

Leave a Reply

Your email address will not be published.