Skip to content

Instantly share code, notes, and snippets.

@spotco
Created August 23, 2014 22:50
Show Gist options
  • Select an option

  • Save spotco/7e9837e2c940eabb059a to your computer and use it in GitHub Desktop.

Select an option

Save spotco/7e9837e2c940eabb059a to your computer and use it in GitHub Desktop.
ss_layers.js
app.preferences.rulerUnits = Units.PIXELS;
var srcDoc = app.activeDocument;
var numOfLayers = srcDoc.layers.length;
var results = "";
for (var i = 0; i < numOfLayers; i++)
{
var theLayer = srcDoc.layers[i];
results += "["+(numOfLayers-i-1)+"]"+theLayer.name+"\n";
}
results+="width:"+srcDoc.width+", height:"+srcDoc.height;
writeTextFile(results);
alert("contents:\n"+results);
function getLayerBounds(alayer)
{
var x1 = parseFloat(alayer.bounds[0])
var y1 = parseFloat(alayer.bounds[1])
var x2 = parseFloat(alayer.bounds[2])
var y2 = parseFloat(alayer.bounds[3])
return [x1,y1,x2,y2]
}
function writeTextFile(output)
{
var file = new File();
var fileNew = file.saveDlg("Save new file");
fileNew.open("w"); //
fileNew.writeln(output);
fileNew.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment