Created
April 25, 2011 07:57
-
-
Save calvinchengx/940263 to your computer and use it in GitHub Desktop.
Export each layer as a PNG from your Illustrator file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var document = app.activeDocument; | |
if(document && folder) | |
{ | |
var options = new ExportOptionsPNG24(); | |
options.antiAliasing = true; | |
options.transparency = true; | |
var n = document.layers.length; | |
for(var i=0; i<n; ++i) | |
{ | |
hideAllLayers(); | |
var layer = document.layers[i]; | |
layer.visible = true; | |
var file = new File(folder.fsName+"/"+layer.name+".png"); | |
var options = new ExportOptionsPNG24(); | |
options.artBoardClipping = true; | |
document.exportFile(file,ExportType.PNG24,options); | |
} | |
showAllLayers(); | |
} | |
function hideAllLayers() | |
{ | |
forEach(document.layers, function(layer) { | |
layer.visible = false; | |
}); | |
} | |
function showAllLayers() | |
{ | |
forEach(document.layers, function(layer) { | |
layer.visible = true; | |
}); | |
} | |
function forEach(collection, fn) | |
{ | |
var n = collection.length; | |
for(var i=0; i<n; ++i) | |
{ | |
fn(collection[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment