chris blogs

April 2004

18apr2004 · Mosaics

Recently, I have been playing with computer-generated mosaics, especially randomly composed ones. I created a nice one with ImageMagick today, using pictures from sxc:

Preview of mosaic
Fullsize view

First, I took the three images (water surface, drops on a leaf, sunset), and cut them into 64x64 pixel sized tiles using

convert -crop 64x64 filename tile-1.png

This creates—depending on the size of the image—about 200 to 500 tiles. Do the same for the other files.

Then, put them together with

montage -geometry 64x64 +frame +shadow +label -borderwidth 2 -bordercolor white -tile 16x16 ls tile-{2,3,4}.png.* | shuffle | head -256 mosaic.png

Of course, adopt -tile and the parameter to head to your needs.

The tool shuffle is like cat, but it prints the lines in arbitrary order, you can write it using ruby in just one line,

ruby -e ‘puts $<.readlines.sort_by { rand }’

If you’re more interested in creating ‘real’ mosaic, that make ‘sense’, you should try pmosaic by Peter Kirchgessner, a GIMP plugin.

NP: Audioslave—Shadow On The Sun

Copyright © 2004–2016