Hello! This website doesn't really support IE that well... might I suggest you give Firefox a try?
Peter Jones
Helloooo readers (and fellow animators)!

After a bit of searching, we couldn't seem to find a complete way to go from a framed animation in Adobe Photoshop to an ideally packed sprite sheet. Lo and behold, the RA Animation Exporter for Adobe Photoshop was born and we'd like to share it with the animating world. Download it now!

Image
From a PSD...

Image
...to a PNG sprite sheet


Click "Read More" to learn more...

Getting it to work requires no programming experience! Many thanks go to jugenjury on ps-scripts.com and Mark McCoy from torquepowered.com who supplied a couple sections of code.

Before we begin:
- Make sure you download these files, which contains: RA Animation Exporter.jsx, example.psd and exampleResult.png
- Have Photoshop CS3 or higher (it should work with CS2)
- Works with PC and Mac!

Using the Animation Tool in Photoshop:
For anyone who's never used Photoshop's animation tool, it's fairly easy to pick up. "Frames" simply alter the visibility, position and style of your layers, not its contents. If there's a layer that remains the same, you can turn its visibility on across all layers.

In terms of this script, you can have as many or as few layers per frame as you wish. Whatever appears in each frame is what will appear in the final sprite sheet. Just make sure there are no blank frames and that all layers are unlocked. I should also note that I use the framed format in Photoshop and not the timeline.

Image
Framed Animation


Here's pretty basic video tutorial on how to get started. Once the background layer is unlocked, the animation in this video should export perfectly.

What the script does:
- Saves the .PSD in order to revert back after the sprite sheet is finished
- Creates a merged copy of each frame
- Using the width, height and number of frames it determines the most optimal size for the final sprite sheet based in powers of two.
- After resizing the canvas, it places each frame in its consecutive order starting at the top left of the canvas.
- Once the final sheet has been laid out, it runs through a process that prevents a white halo appearing on the image. If you're unfamiliar with "White Halos", you can learn more about about it from our friends at Blurst.
- Finally it uses Photoshop's Save For Web and exports the sprite sheet as a PNG-24 onto your desktop under the same name as the .PSD.

Photoshop, javascript and you:
Working with Javascript and Photoshop actually became surprisingly easy. The two most valuable sources are the Adobe Photoshop Scripting Guide and the Photoshop Script Listener (found on page 73 in the Scripting Guide).

Basically the script listener will log any action taken in Photoshop into a text file on your desktop. If you look at my script, the bits of incoherent code are from the script listener. I added a comment on top of each section with what it does for easy reference.

The script that we use has a few more features catered to our own engine. Here's an example that you might find useful for adding your own functionality:

var answer = confirm("Write a text file?");

if (answer == true) {
fileOut.open = new File("~\Desktop\fileName.txt");
fileOut.open("w", "TEXT", "????");
fileOut.write("Number of Frames:" + numFrames);
}
This prompts the user with a yes or no question and writes a text file on your desktop if they say yes.


Installation:
First off, I've provided a .PSD that has a basic animation and a .PNG with what the script should output to your desktop. Once you download all three things, let's put the .JSX in the right place!

Navigate to your Adobe Photoshop directory and place the .JSX into

Image
Adobe Photoshop CS4\Presets\Scripts


Launch Photoshop (or relaunch if it was open). Open up the example.psd I gave you; an 11 frame, bouncing ball. Run the script by going to File » Scripts and choose RA Animation Exporter. If for some reason it's not there, you can click Browse instead and locate RA Animation Exporter.jsx manually. The end result should be an image called example.png on your desktop that looks exactly like the exampleResult.png I provided.

Known issues:
I wrote and use it with CS4, it seems to work well with CS3 and I haven't tired it with CS2, the version Animation first appeared. If you do, let me know! Here are a few things to keep in mind:

- Make sure there are at least two frames of animation
- Make sure there are no locked layers in the .psd
- Make sure every frame has at least one layer visible

Feel free to post comments, suggestions or any changes you've made yourself!

***Updated February 4th, 2010***
v1.1

Bug Fixes:
- Fixed an issue that caused some PSDs to set all layers to 0% opacity before placing them in a sprite sheet.

New Features:
- For pixelated animations, you can now turn off the "dehalo" section by opening the script and changing:

var dehaloImage = 1;
to
var dehaloImage = 0;

***Updated March 1st, 2010***
v1.2


New Features:
- You can now have the exporter put your frames one after another in a single row.

Under the new Settings section of code in the script, change:
var sheetGrid = 1;
to
var sheetGrid = 0;


*** ***


Download the RA Animation Exporter v1.2

Comments

Ben Ruiz

January 19th, 2010 7:05:23 pm

This really great shit, thanks a lot guys!

Anonymous

January 23rd, 2010 2:52:32 am

This is awesome! woot woot woot woot, thanks a lot.

zeroZshadow

January 27th, 2010 11:52:46 am

I get a crash " Error 8800 Generar error, couldn't do gaussian blur because the selected area is empty"

Peter

January 28th, 2010 12:07:21 pm

Hey zeroZshadow,

I tried recreating the error myself but can't quite reproduce it. Would you mind sending a copy of the .PSD that's causing it to info@retroaffect.com? Thanks!

Rich Grillotti

February 4th, 2010 10:32:37 am

Wow, this will really be helpful. Thanks! I am running into the same gaussian blur error though..

Peter

February 4th, 2010 10:39:34 am

I'm glad you found it helpful! zeroZshadow was unable to send his PSD, do you think you could send a copy of your PSD causing the error so I can get to the bottom of it? It'd be much appreciated, thanks!

info@retroaffect.com

Peter

February 4th, 2010 2:34:34 pm

I just posted version 1.1 that should solve the Gaussian Blur error. I also included an easy way to turn off the "dehalo" feature; which you'll want to do if you're creating pixelated animations.

Let me know if you get any other errors and I'll do my best to address them!

Lena

February 27th, 2010 7:47:50 pm

Fantastic script...this will really help me produce artwork quickly for a game I'm working on.

I had one minor issue - seems to create a sprite that's about 2 tiles wider and 1 tile taller than it needs to be. PSD includes a bunch of adjustment layers...don't know if that's the cause.

Tiny request - is there a way to modify the script to make a strip instead of a grid?

Thanks again!

Peter

March 1st, 2010 8:26:43 am

Hi Lena

Thanks! I'm glad it's helping you out. I've uploaded v1.2 which includes the ability to export to a strip instead of a grid. Just change the var sheetGrid to 0, instead of 1.

As for your other issue, the sheet exports to the smallest (and most optimal) power of two possible...there's most likely a decent amount of white space due to that. Do you think that could be it?

Lena

March 2nd, 2010 12:53:08 am

Wow...thanks! works perfectly :D

I can't replicate the other issue as I've since changed the artwork, but I suspect you're right. I'm pretty sure it was an odd frame count.

Meanwhile, I have RSSed this awesome blog.

Mike

April 18th, 2010 11:31:22 pm

Peter:
You have a great blog! I tried the script with example.psd, but it appears to not work with CS2. (Pop-up says error at line 159).

Cheers and Thanks,
Mike

Anonymous

April 26th, 2010 9:15:31 am

Get an error on line 310 in CS4 when running the script

Error 8800: General photoshop error occured. This functionality may not be available in this version of photoshop.
-The command "Delete" is not currently available - Line: 310 -> executeAction(idDlt, desc8, DialogModes.No); Hopefully you can fix this :)

Peter

April 27th, 2010 10:58:26 am

Hmm, if you could send me (info@retroaffect.com) the Photoshop file that causes the error, I think I could figure it out in a jiffy. Until then, I'll try recreating it myself. Thanks!

k00k

April 28th, 2010 6:38:08 pm

awsome I will send it over your tool is a huge help man!

sabri

June 30th, 2010 4:03:09 am

This is awesome! Thanks a lot Peter.
By the way, can we decide the dimensions of the sheet somehow?

Thanks

Gillissie

June 30th, 2010 3:58:47 pm

Bummer, PS crashes when I try to use it (CS3). I don't know if it really does what I'm looking for anyway. What I really need is a script similar to "Load files into stack", except instead of a stack I want a sprite sheet with a specified number of rows and columns.

Jon

July 27th, 2010 1:37:13 am

Hi Peter,
this was exactly what I was looking for.
Only thing, I'm looking for a quick way to automate turning quadrillions of .mov files to single sprite sheets. In PS cs3 you can't import a whole folder or more than one file (open yea, import nay). Won't work with batching either. Is there something I can change in the script that will let me not just IMPORT VID FRAMES TO LAYERS but rather OPEN the .movs (or sequences, whatever) to convert them. That would make my day. My week actually, literally.

TESTING




Post Comment!
Loading

Other Info

Retro Affect LLC
4380 E Marshall Ct
Gilbert AZ 85297
info@retroaffect.com

Find Something

Follow us on Twitter
Look at us on Flickr
Watch us on YouTube
Friend us on Facebook