Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Forked from JakeRTFM/gist:6165876
Last active April 21, 2019 22:57
Show Gist options
  • Save Arahnoid/3425dbd0211cd2cb4cbc to your computer and use it in GitHub Desktop.
Save Arahnoid/3425dbd0211cd2cb4cbc to your computer and use it in GitHub Desktop.
[Get PNG from layers]Get PNG from layer in a group by hide/show one by one #Photoshop
main();
function main(){
var doc = activeDocument;
var docPath = activeDocument.path;
var marketApps = doc.layerSets.getByName("Group Name");
for(var a=0; a<marketApps.layers.length; a++){
//alert(marketApps.layers[a]);
marketApps.layers[a].visible = true;
saveAsPNG(marketApps.layers[a].name);
marketApps.layers[a].visible = false;
}
// LayerSets = group
alert(marketApps.layers.length);
}
function saveAsPNG(nameFile){
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if(Ext.toLowerCase() != 'psd') return;
var Path = app.activeDocument.path;
var saveFile = File(Path + "/" + nameFile +".png");
if(saveFile.exists) saveFile.remove();
SavePNG(saveFile);
}
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment