Created
January 21, 2024 09:29
-
-
Save Ending2015a/cde33e8a0b36818baec352fecb124dbf to your computer and use it in GitHub Desktop.
Photopea export all group layers (folders) into separated PNG files.
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
function GetDocName(){ | |
var split = app.activeDocument.name.split('.'); | |
split.pop(); | |
var docName = split.join("."); | |
return docName; | |
} | |
function SavePNG(saveFile){ | |
var pngOpts = new ExportOptionsSaveForWeb; | |
pngOpts.format = SaveDocumentType.PNG | |
pngOpts.PNG8 = false; | |
pngOpts.transparency = false; | |
pngOpts.interlaced = false; | |
pngOpts.quality = 100; | |
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts); | |
} | |
function ExportLayers(){ | |
var layers = app.activeDocument.layers; | |
var docName = GetDocName(); | |
var numLayers = layers.length; | |
var excludeLast = true; | |
if(excludeLast) numLayers--; | |
for (var i=0;i<numLayers; i++){ | |
for (var j=0;j<layers.length; j++){ | |
layers[j].visible = false; | |
} | |
layers[i].visible = true; | |
SavePNG(docName + '-' + layers[i].name + '.png'); | |
} | |
} | |
ExportLayers() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment