Quick Image Montages
(Mostly notes to myself.)
If you have a lot of images in a directory, and want to quickly make an image montage, here's how to do it on Linux using ImageMagick.
First up, this command finds all JPG file, then resizes them so they fit in a maximum box of 256x256, then sets the quality to 75%, then saves them as JPGs:
find ./ -type f -iname "*.jpg" -exec mogrify -verbose -format jpg -layers Dispose -resize 256\>x256\> -quality 75% {} +
This will overwrite your existing files so make sure you have a backup.
This will take all JPG files, and then arrange them in a montage which is 10 images wide and 5 images high, with no padding between the images, and then save them as a file called "montage.png":
montage *.jpg -tile 10x5 -geometry +0+0 montage.png
If you have more than 10x5 images, this will spit out multiple files. If you want to specify the width, but not the height, use:
montage *.jpg -tile 10x -geometry +0+0 montage.png
Handy if you can't be bothered counting how many images you have.
The ordering is "sort of alphabetical". That is, it sorts them by first character. You may want to renumber your files as 00001.jpg
etc if you have a specific ordering in mind.
The output looks like this:
Neil Brown said on twitter.com:
This is brilliant. Thank you.
mike says:
Maybe you're aware of this already and did in two steps for a specific reason, but if you're not bothered about ordering you can make the montage in one step by making use of the ImageMagick MIFF format
find /some/images/ -type f -iname "*.jpg" -exec convert -resize 256>x256> {} MIFF:- \; | montage - -tile 10x5 -geometry +0+0 -quality 72 /tmp/montage.jpg
The ordering will be directory order as that's what find outputs in (or at least it does in my observation see also "ls -U").
Tom says:
This reminded me of a tool I used years ago to make a photomosaic piece for a local history exhibition, Metapixel (http://www.complang.tuwien.ac.at/schani/metapixel/). I wonder if you can achieve similar results with some montage magic!