Skip to content

Instantly share code, notes, and snippets.

@JakeRTFM
Last active December 20, 2015 16:59
Show Gist options
  • Save JakeRTFM/6165876 to your computer and use it in GitHub Desktop.
Save JakeRTFM/6165876 to your computer and use it in GitHub Desktop.
Photoshop script for get PNG from layer in a group by hide/show one by one.
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