ExtendScript (Photoshop, InDesign, Illustrator) export selection as PNG
Using ExtendScript Toolkit you can create scripts for use in Photoshop, InDesign and Illustrator. The documentation isn't quite good, but if you want to save the selection as separate transparent PNG's, use this:
var prefixFilename = prompt("Filename:", "layer");
for ( var i = 0; i < app.selection.length; i++ )
{
var myFile = File("~/Desktop/"+prefixFilename+"-"+i+".png"); // Works on Mac. Use another path for Windows
app.selection[i].exportFile(ExportFormat.PNG_FORMAT, myFile, true);
}
For saving the selection as separate JPG's, use this:
var prefixFilename = prompt("Filename:", "layer");
for ( var i = 0; i < app.selection.length; i++ )
{
var myFile = File("~/Desktop/"+prefixFilename+"-"+i+".jpg"); // Works on Mac. Use another path for Windows
app.selection[i].exportFile(ExportFormat.JPG, myFile, false);
}
Written by Denver Sessink
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Script
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#