Some people make them out of toast
some use newspaper
and some even use toothpicks
but Linux users have it easy. When it comes to making mosaics, all you
really is Metapixel
Metapixel is a command-line tool that creates photomosaics
-- pictures in which the original image is rebuilt using a
of much smaller images. The effect can be stunning ...
... when you look closely ...
(Check out this
link to see the original in its full glory.)
need two things to turn an picture into a mosaic; a source image --
obviously -- and a library of "tiles" from which to build the
final picture. But first, the software ...
Ubuntu and Debian users can simply open a console window and
|sudo apt-get install metapixel
Linux users should check their repositories. Metapixel seems to be a
standard addition, but if all else fails check out their homepage
Creating a tile library
single-stage process actually does two things; it scales images down to
a manageable tile size and computes various
factors that will be used to match pixels in the source image. The
source library, the better, and in Linux we have an ideal one in /usr/share/icons
First, create a new directory in which to store the tiles:
Then tell metapixel to populate it:
|metapixel-prepare -r /usr/share/icons
tile_library --width=32 --height=32
tells metapixel-prepare to recurse all sub-directories under /usr/share/icons.
is our newly created tile directory.
set the width and height of the tiles. (I find the default, 128x128, a
little too large!)
Notes that Metapixel only
recognises JPG, PNG and GIF files, anything else generates an error
message and is ignored. After several
minutes processing, I found my library filled
with more than 10,000 "tiles".
Now for the fun bit. Building a mosaic is as simple as typing ...
--library tile_library --metapixel original.jpg target.jpg
but depending on the size of your original, the results may not
be too spectacular. Allow me to demonstrate. Here's my original:
(It's the 128x128 pixel penguin.png icon given
a white background and renamed penguin.jpg.)
And here's the result :
When you think about it, it's not too surprising. We're mapping 32x32
pixel tiles onto a 128x128 pixel image. The most we're ever
going to get
is four tiles across and four down!
There are two solutions. The first is to use smaller tiles. We can
force this be declaring their height and width:
--library tile_library --metapixel original.jpg target.jpg height=8
This produces a much more satisfactory result:
The other alternative is to use the "scale" parameter to resize the
original before the tiles are applied.
--library tile_library --metapixel original.jpg target.jpg -s 20
scale 20x, meaning Metapixel will work from a 2560x2560 image -- and
generate one of that size! Here's the result, squeezed down to a mere
400x400 to fit on this page:
(To study it's full splendour, just click on the image.)
You can of course combine both scale
parameters for even more detail.
one other option to be aware of. By default Metapixel
produces "traditional" mosaics that use evenly spaced tiles,
but add the --collage
parameter and it will overlay them to get the best resolution.
Here's a couple of examples to demonstrate the difference. Both are
details of the penguin's eyes and upper beak ...
The same area using the --collage
Processing takes a little longer when using --collage
reckon it's worth it.
Check out some of the examples here
(Click on the images to display them full-size.) Awesome!