Skip to content

Instantly share code, notes, and snippets.

@psql
Created August 9, 2012 18:28
Show Gist options
  • Save psql/3306838 to your computer and use it in GitHub Desktop.
Save psql/3306838 to your computer and use it in GitHub Desktop.
Photoshop layer stack to horizontal sprite
if (documents.length > 0)
{
var docRef = activeDocument;
var activeLayer = docRef.activeLayer;
numLayers = docRef.artLayers.length;
var rows = numLayers;
var spriteX = docRef.width;
var spriteY = docRef.height;
app.preferences.rulerUnits = Units.PIXELS;
docRef.resizeCanvas( spriteX * rows, spriteY, AnchorPosition.TOPLEFT );
for (i=0;i < numLayers ;i++)
{
docRef.artLayers[i].visible = true;
var movX = spriteX*i;
docRef.artLayers[i].translate(movX, 0);
}
}else
{
msg("Sorry must have more than 1 image open in photoshop to work!");
}
@psql
Copy link
Author

psql commented Aug 9, 2012

Stripped this out of something I found a long time ago. Trying to work out how to stack vertically instead.

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