Quick n' easy mosaics with ImageMagick
Creating a mosaic of several images is boring grunt work. Luckly it can be automated! ImageMagick can easily create a mosaic of many images with just one command: montage
You can run montage with a list of images you want to put in a mosaic like this:
montage image_1.jpg image_2.jpg image_3.jpg image_4.jpg mosaic.jpg
Note that we need a final parameter for the output filepath. The real power, though comes from using shell wildcards like this:
montage *.jpg mosaic.jpg
You can also tell montage to fit the images in a specific size using the geometry parameter. Notice the size defines the cell size and images will fit inside it, keeping their ratios while smaller images will not be resized. Geometry also takes a value for the spacing 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 possible to give it a certain amout of tiles with the tile command
montage -tile 4x1 *.jpg mosaic.jpg
What about cropping images instead of resizing? The crop parameter takes a size in pixels (width x height) or a percentage, along with a position (+x+y).
montage -crop 1000x1000+0+0 *.jpg mosaic.jpg
montage -crop 1000x1000+500+0 *.jpg mosaic.jpg
Finally we can get rid of the gaps with -mode concatenate. Watch out though, if one of the images is smaller and you’re not cropping 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 shadows, borders, labels and plenty of other cool tricks! Check out the montage documentation for more info.
The awesome food photos come from Pixabay.com.