Skip to content

Instantly share code, notes, and snippets.

@jessefreeman
Created March 15, 2011 01:15
Show Gist options
  • Save jessefreeman/870172 to your computer and use it in GitHub Desktop.
Save jessefreeman/870172 to your computer and use it in GitHub Desktop.
This is a PS script to make Sprite Sheets out of layers. Modified from http://www.garagegames.com/community/blogs/view/11527
// Put this file in Program Files\Adobe\Photoshop\Presets\Scripts\
// In PhotoShop menu File > Automate > Scripts: layersToSprite.js
// Arrange layers into a sprite sheet.
if (documents.length > 0)
{
// --------------------------
docRef = activeDocument;
var activeLayer = docRef.activeLayer;
numLayers = docRef.artLayers.length;
var cols = docRef.width;
var spriteX = docRef.width;
// put things in order
app.preferences.rulerUnits = Units.PIXELS;
// resize the canvas
newX = numLayers * spriteX;
docRef.resizeCanvas( newX, docRef.height, AnchorPosition.TOPLEFT );
// move the layers around
for (i=0; i < numLayers; i++)
{
docRef.artLayers[i].visible = 1;
var movX = spriteX*i;
docRef.artLayers[i].translate(movX, 0);
}
}
@szegheo
Copy link

szegheo commented Apr 29, 2021

Thank you @jessefreeman and @jsonacob (I was needed a vertical solution) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment