What is the best way to create a single PNG image containing multiple PNGs of the same size?

5

2

What is the best way to create a single PNG image that contains multiple PNGs of the same size, such as 32x32 and 64x64?

I have a lot of images that I need to include in a single image so I can load them all as just one image. I only have access to open source tools. I need a fast/efficient way to do this. Is such an image called a sprite or a tile?

Androider

Posted 2011-12-12T01:48:52.307

Reputation: 165

Answers

5

When used in reference to images used in websites, combining images like this is referred to as a CSS sprite.

You can use the Imagemagick (open source) montage tool to quickly combine your icons into a big file.

This would make a 5x5 tile single image of everything in the current folder:

montage -background transparent -tile 5x5 *.png sprite.png

If there are less than 25 images, then blank spaces will be used. The last file on the command line is the output file.

Imagemagick is a command line tool and so often the fastest and most efficient way to do what you want.

Paul

Posted 2011-12-12T01:48:52.307

Reputation: 52 173

Yes, montage allows you to tile multiple image, with customized border, padding, number of rows/columns... – jcisio – 2011-12-12T03:26:40.890

what could a montage command look like to combine icons into a single file? say all icons in a given directory? most likely I will want to place them one row by row or column by column. – Androider – 2011-12-12T06:19:18.497

I added an example to the answer – Paul – 2011-12-12T08:29:32.713