How to Create Beautiful Photomosaics in Linux Using Metapixel

Printer-friendly versionPDF version
Linux Metapixel

Metapixel is a program for generating photomosaics. It can generate classical photomosaics, in which the source image is viewed as a matrix of equally sized rectangles for each of which a matching image is substitued, as well as collage-style photomosaics, in which rectangular parts of the source image at arbitrary positions (i.e. not aligned to a matrix) are substituted by matching images.

To install metapixel, run the following commands (you will need unrar to extract the wallpaper packs. If you have your own image collection, you do not need to install unrar):

Ubuntu (Tested on11.10): sudo apt-get install metapixel unrar

openSUSE (Tested on 12.1) 32bit: wget

sudo zypper install ./metapixel-1.0.2-1.2.i586.rpm unrar

openSUSE (Tested on 12.1) 64bit: wget

sudo zypper install ./metapixel-1.0.2-1.2.x86_64.rpm unrar

In order to use metapixel, you need an image collection and a source image (like the one above, which you can download in the steps below). Metapixel only supports jpeg and png images. If you already have an image collection, you can use it as the source folder, otherwise, here is a collection of wallpapers you can use (thanks to for hosting these wallpaper packs):


This pack has 784 images in it. The reason I chose it for my example is because it's only 127 MB. If you need more images (which you will, if you want a better looking photomosaic), download this wallpaper pack instead:


Run the following commands to create your metapixel working directories, download the source image, and unpack the wallpaper pack:

mkdir mp mp/small mp/photo

cd mp


unrar e ../"Santods Ultimate Walls Landscape  Pack.rar" photo/

Before running metapixel, you must prepare the images:

metapixel-prepare -r ./photo ./small --width=32 --height=32

This takes all the images you unpacked in the photo directory, resizes them to 32x32, and places them in the directory named small. To make a photomosaic of your source image, run the following command:

metapixel --metapixel ./animated+linux+wallpaper.jpg photomosaic.png --library ./small/ --scale=10


This scales the original image by 10, then arranges the 32x32 images to fit inside the scaled up source image. Take a closer look:


​To make a collage style photomosaic, run the following command:

metapixel --collage --metapixel ./animated+linux+wallpaper.jpg photomosaic2.png --library ./small/ --scale=10


As you can see, it's a little more detailed. The 32x32 images overlap each other, providing more depth and clarity. Using the --collage switch will increase the processing time significantly, but it's worth the wait if you want a better quality result. Take a closer look again:


You can also add the --distance=300 option to ensure duplicate images won't be placed near each other. Using the --distance option will also increase the processing time. If you use it, you must make sure that you have a large enough image collection for the spacing to work.

To find out more about metapixel and all of the command line options, check out the readme file and the project's homepage:

Thanks to Matthew Gerber, there is a GUI available for metapixel. Check it out here:

Hi, you have scaled the original images to 32x32 pixels. Is the aspect ratio kept?
Ciao, Leo

The aspect ratio is not kept. I chose 32x32 because it is so small that you can't really tell the aspect ratio is lost. If you wanted to keep the aspect ratio for the pictures I linked to, you would have to do it like this:

The images are 800x480. To retain the aspect ratio, you would need to make the images 32x19.2. Since metapixel only accepts whole numbers, you would run this command to prepare the images:

metapixel-prepare -r ./photo ./small --width=32 --height=19

Post new comment