A sprite sheet is basically a collection of individual images (or frames) arranged together as a single image. By quickly moving the position of the sprite sheet at timed intervals within a viewport, an animation can be created.
Sprite sheets are used in all kinds of software and are commonly used in web development for framed animation. There are some specific tools and online services that can help create sprite sheets, but if you’re using PhotoShop you can make this process really easy using the below steps.
This article will run through the process of how to automate sprite sheet creation in PhotoShop using a series of individual images for each frame in an animation, such as the sprite sheet below which I’m using for the new Web Dev Door website. These frames were initially created using 3D software.
You can download and install the PhotoShop Sprite Sheet Exporter extension here, (from asousa.com). Unzip and install via Adobe Extension Manager.
There are a number of in-built methods within PhotoShop that may get you close to a decent sprite sheet, such as ‘Contact Sheet’ and ‘PhotoMerge’ functions. I’ve found the Sprite Sheet Exporter plugin to be the best method so far. This should work for most versions of PhotoShop and works well in PhotoShop CS5 and CS6.
Before we can use the Sprite Sheet exporter, we need all our individual frames on separate layers within PhotoShop, with the first frame as the top layer and last frame as bottom. The easiest way I’ve found to do this is to follow these steps:
The stacking script will take a number of seconds to run depending how many images are selected, as the script has to open, create a new layer, paste and close each image that is being imported. Images are stacked into layers by name, so a good idea to name your frames sequentially i.e. image001.png, image002.png etc.
We should now have all our frames as separate layers, with the top most layer the one which will be the first frame our sprite sheet. If layers have imported in the wrong order, we can quickly reverse the layer stack by selecting all layers and going through the menu options Layer->Arrange->Reverse.
Don’t worry if your images are different sizes either; when the sprite sheet is created, the exporter will pack each image with an equal width and height between each frame. This is what we want with a sprite sheet, as we don’t have to manually declare the position of each frame when animating.
Now that you have each image as an individual layer, save your file and run the ‘Sprite Sheet Exporter’ script from Files->Scripts. The resulting sprite sheet will be created and saved in the same place as your saved file.
The exported sprite sheet image will be as a transparent PNG by default but you may wish to open and re-export to a .jpg or other format for better compression. If you need the transparency and are happy to stick with a .png for your sprite sheet, I would recommend running this through a .png optimiser such as tinypng.org.
Optimising png images not only reduces file size but can make your animations run smoother.