Our artist has been working hard drawing all the graphics for our new game (more info to come on that front). She’s been working on the main character’s animations recently. These are complex animations with many frames and, to ensure they line up properly, she draws all the frames within a canvas the size of a single frame and separates the layers into layer sets. This is to ensure that the image for each frame of the animation aligns correctly with the frame before it.

However, our animation system in the game requires that each frame is drawn separately from left to right. Even with the layer sets, it’s still a lot of annoying manual work to move and align each frame while ensuring they’ll draw the same as they did in the single-frame-sized canvas. I recently found out that you can script for PS and so this set me thinking: there must be a way to write a script that can do this!

So, that’s what this is. I’m not going to get into too much detail other than to say that it looks like you can pretty much do anything from the Photoshop GUI with scripting. The other great thing about it is that you can pick your language. It supports apple script (on Macs), VBScript (on Windows) and JavaScript (on both). Of course, I chose JavaScript and after perusing the documentation, I was able to whip up a script within 30mins.

The basic goals of the script were to:

  1. Enumerate all visible layer sets
  2. Expand the canvas width by 1 frame width times the number of visible layer sets
  3. Move each layer set into it’s own frame section

So I did this, found some bugs and then added some error checking. This script is the culmination of that:

Note: I added some line breaks to make this fit into my theme.

To use it, you just have to save it in your Photoshop Directrory/Presets/Scripts folder with the name “Make Tiled.jsx”. Then run it from the File > Scripts menu.

I do want to do a write up about scripting in PS but for now I’m just going to post the file in case you want to use it. Click here to download it.