Export Groups to Files?

New Here ,
Sep 06, 2009

Copy link to clipboard

Copied

Is there a way to export multiple GROUPS into individual files, such as jpg?  If I run the File > Scripts > Export LAYERS To Files, each LAYER becomes a jpeg, but i'd like each GROUP to be flattened and exported as a jpg. Is there a script or funtion that performs this task?

TOPICS
Actions and scripting

Views

92.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 06, 2009 1
LEGEND ,
Sep 07, 2009

Copy link to clipboard

Copied

Are all the groups on the topmost hierarchical level or are there groups within groups?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 07, 2009 0
LEGEND ,
Sep 08, 2009

Copy link to clipboard

Copied

You could try attached Script, You’d have to adapt it to jpg, currently it saves pdfs.

I have not tested it very extensively and only in CS4 though.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 08, 2009 4
New Here ,
Sep 09, 2009

Copy link to clipboard

Copied

Yes, the Groups are all at the top level, and YES! your script worked wonderfully!  I'll need to figure out the jpg instead of pdf portion, but you definitely solved the difficult part. Thank you!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 09, 2009 0
LEGEND ,
Sep 09, 2009

Copy link to clipboard

Copied

You could replace the pdfOptions with

var jpgopts = new JPEGSaveOptions();

jpgopts.embedColorProfile = true;

jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;

jpgopts.matte = MatteType.NONE;

jpgopts.quality = 10;

and edit that according to Your needs.

Then replace »pdfOpts« and ».pdf« in the saveAs-line with »jpgopts« and ».jpg«.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 09, 2009 4
Community Beginner ,
Mar 16, 2010

Copy link to clipboard

Copied

Great skript!

Is there a way to export Groups to png?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 16, 2010 0
New Here ,
Sep 14, 2011

Copy link to clipboard

Copied

if you guys are still around, and can help I would love it. Exact same problems and needs to everyone here above. I have NO knowledge of editing scrips. The one for PDF worked but as you know really time consuming to then convert PDF to JPEGS. Can someone provide me the the script to download which works for converting the layer groups to .jpeg.

I would very very much appreciate it. I tried to edit the code for the script but very shamefull unsuccessful

Thank you

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 14, 2011 0
LEGEND ,
Sep 15, 2011

Copy link to clipboard

Copied

The Script from which post are you referring to exactly?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2011 0
Valorous Hero ,
Sep 15, 2011

Copy link to clipboard

Copied

Have you tried this one?

http://www.scriptsrus.talktalk.net/Layer%20Saver.htm

This supports jpeg

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2011 0
New Here ,
Sep 15, 2011

Copy link to clipboard

Copied

You are an absolute legend. Thanks mate. You saved my life. thanks thanks thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2011 0
New Here ,
Dec 21, 2011

Copy link to clipboard

Copied

Fantastic script!  Is there a way to have this script combine the exported JPG's or PDF's into a single PDF?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 21, 2011 0
Valorous Hero ,
Dec 21, 2011

Copy link to clipboard

Copied

Sorry but the option of creating multipage PDFs was removed in Photoshop CS4 and that functionality was moved to Bridge and that process is not scriptable.

So if you have Photoshop CS2 or CS3 you could open all the JPGs and use File - Automate - PDF Presentation to create your pdf.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 21, 2011 0
New Here ,
Nov 28, 2013

Copy link to clipboard

Copied

Hi Paul,

The link is down, can you upload it again?

This script 'd really save me some valuable time

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 28, 2013 0
Engaged ,
Nov 28, 2013

Copy link to clipboard

Copied

try this, the layer saver is towards the bottom of the list:

http://www.ps-bridge-scripts.talktalk.net/

Paul makes some very useful scripts, thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 28, 2013 1
LEGEND ,
Nov 28, 2013

Copy link to clipboard

Copied

Paul makes some very useful scripts, thanks!

Alas, if I remember correctly he stopped participating in these Fora because of his frustration with Adobe’s bug fixing neglect.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 28, 2013 0
Community Beginner ,
Sep 28, 2018

Copy link to clipboard

Copied

Could you please help me to Export Artboards PNG and Ai?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 28, 2018 1
New Here ,
Nov 13, 2018

Copy link to clipboard

Copied

Thanks a lot for this script! It helps me and automate my routine work !!!
Does the script make all other layers invisible when export the current group? May I change it? I need some layers that I choose visible stay visible during exporting groups. For example I made a storyboard. And it has in the bottom unchangeable bg white colors and a picture borders - white rectangle with black stroke, and in each group I draw frames, and in each group there aren't bg and picture borders. I switch off visibility of groups, but bg and borders are always visible. To see them on each jpg I should to copy and paste them in each group. Can I avoid it with your script?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 13, 2018 0
LEGEND ,
Nov 25, 2018

Copy link to clipboard

Copied

Which exact Script are you referring to?

Could you post a screenshot of the file’s Layers Panel to illustrate the Layer structure and clarify which Layers you want to »fixate«?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 25, 2018 0
New Here ,
Apr 24, 2015

Copy link to clipboard

Copied

Hello,

I'm looking to do the same (export all top level groups as images). Is there an updated script that works in CC?

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 24, 2015 0
LEGEND ,
Apr 26, 2015

Copy link to clipboard

Copied

Doe the Script fail for you in CC and if so how exactly?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2015 0
New Here ,
Apr 29, 2015

Copy link to clipboard

Copied

I am running an older version of Paul's script and I'm getting a crash on Photoshop CC 64-bit, no error is thrown, program just shuts down.  Seems to work on the 32-bit version though.  Also, the links to the newer version of this script are empty, is there anywhere I can get the most updated version of this?

Thanks in advance!

-Kris

EDIT:  Link is working for me now and I downloaded the latest version of "Layer Saver".  Still crashes CC 64-bit, and CC 32-bit seems to not finish the task when started.

Anyone get this working in Photoshop CC 32 or 64 bit?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 29, 2015 0
New Here ,
Jan 05, 2016

Copy link to clipboard

Copied

Hope you found the answer to this already but I'll answer anyway, for future reference:
it really helped me to find out that in photoshop cc you can save groups as simply as by selecting the ones you want,right clicking the mouse and selecting the "export as..." option. It saved me around 30 min per project!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 05, 2016 0
Community Beginner ,
Mar 15, 2016

Copy link to clipboard

Copied

Yeah but what if you have like 50 layer groups and you want to save each group as a separate file?  Your suggested method is great for exporting one or two but so much in a batch scenario. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 15, 2016 1
New Here ,
Apr 30, 2016

Copy link to clipboard

Copied

Same, i need to save like 30 layers and it takes lot of time selecting each layer from groups

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 30, 2016 0
LEGEND ,
May 01, 2016

Copy link to clipboard

Copied

If you can clarify the scenario (Layer and Group structure etc.) you could ask for help over at

Photoshop Scripting

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 01, 2016 0
New Here ,
Sep 12, 2009

Copy link to clipboard

Copied

Thanks for this, it works really well. I've tried making 2 changes to the script but it doesn't seem to work right

  • Use ExportOptionsSaveForWeb with JPEG 80% but it's giving me just 1 bad quality file
  • Have the script elaborate only the top level groups to reduce the time it takes to load up and show the dialog box. At the moment it's picking up every group in the file.

What is wrong in this code?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 12, 2009 0
New Here ,
Sep 12, 2009

Copy link to clipboard

Copied

Thanks for this, it works really well. I've tried making 2 changes to the script but it doesn't seem to work right

  • Use ExportOptionsSaveForWeb with JPEG 80% but it's giving me just 1 file name "filename-#0.jpg" with the contents of the lowest group
  • Have the script elaborate only the top level groups to reduce the time it takes to load up and show the dialog box. At the moment it's picking up every group in the file.

What is wrong in this code?

// creates pdf-copies of layersets with dialog to select layers and suffix;

// be advised: existing files of identical names will be overwritten without warnings;

// 2009, pfaffenbichler, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

////////////////////////////////////

// get document-path and -title;

var myDocument = app.activeDocument;

var myDocName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var myPath = myDocument.path;

var theLayerSets = collectLayerSets(myDocument);

////// filter for checking if entry is numeric, thanks to xbytor //////

numberKeystrokeFilter = function() {

this.text = this.text.replace(",", "");

this.text = this.text.replace(".", "");

if (this.text.match(/[^\-\.\d]/)) {

this.text = this.text.replace(/[^\-\.\d]/g, "");

};

if (this.text == "") {

this.text = "0"

}

};

////////////////////////////////////

// create the dialog;

var dlg = new Window('dialog', "pdfs from layersets", [500,300,930,840]);

//create list for layer-selection;

dlg.layerRange = dlg.add('panel', [21,20,279,445], "select layersets to create pdfs of");

dlg.layerRange.layersList = dlg.layerRange.add('listbox', [11,20,240,405], '', {multiselect: true});

for (var q = 0; q < theLayerSets.length; q++) {

dlg.layerRange.layersList.add ("item", theLayerSets.name);

dlg.layerRange.layersList.items.selected = true

};

// entry for suffix;

dlg.suffix = dlg.add('panel', [290,20,410,85], "enter suffix");

dlg.suffix.suffixText = dlg.suffix.add('edittext', [11,20,99,40], "", {multiline:false});

// entry for number;

dlg.number = dlg.add('panel', [290,100,410,165], "start with #");

dlg.number.startNumber = dlg.number.add('edittext', [11,20,45,40], "1", {multiline:false});

dlg.number.addNumber = dlg.number.add('checkbox', [55,20,105,40], "add", {multiline:false});

dlg.number.startNumber.onChange = numberKeystrokeFilter;

// field to add layer-name;

dlg.layerName = dlg.add('panel', [290,180,410,270], "layer-name");

dlg.layerName.doAddName = dlg.layerName.add('radiobutton', [11,20,120,40], "add it");

dlg.layerName.dontAddName = dlg.layerName.add('radiobutton', [11,45,120,65], "don’t add it");

dlg.layerName.doAddName.value = true;

// field to select target-folder;

dlg.target = dlg.add('panel', [290,285,410,445], "target-folder");

dlg.target.targetSel = dlg.target.add('button', [11,20,100,40], "select");

dlg.target.targetField = dlg.target.add('statictext', [11,50,100,155], String(myPath), {multiline:true});

dlg.target.targetSel.onClick = function () {

var target = Folder.selectDialog("select a target folder");

dlg.target.targetField.text = target.fsName

};

// ok- and cancel-buttons;

dlg.buildBtn = dlg.add('button', [220,460,410,475], 'OK', {name:'ok'});

dlg.cancelBtn = dlg.add('button', [21,460,210,475], 'Cancel', {name:'cancel'});

dlg.warning = dlg.add('statictext', [21,490,410,530], "be advised: existing files of the same name will be replaced without prompting", {multiline: true});

dlg.center();

////////////////////////////////////

var myReturn = dlg.show ();

// in case of OK;

if (myReturn == true && dlg.layerRange.layersList.selection.length > 0) {

// get the number instead of the name;

var theLayerSelection = new Array;

var theColl = dlg.layerRange.layersList.items;

for (var p = 0; p < dlg.layerRange.layersList.items.length; p++) {

if (dlg.layerRange.layersList.items

.selected == true) {

theLayerSelection = theLayerSelection.concat(p);

}

};

// collect the rest of the variables,

var theSuffix = dlg.suffix.suffixText.text;

var theNumber = Number (dlg.number.startNumber.text) - 1;

var theLayerNameAdd = dlg.layerName.doAddName.value;

var theDestination = dlg.target.targetField.text;

var theNumbering = dlg.number.addNumber.value;

// pdf options

var jpgopts = new ExportOptionsSaveForWeb();

jpgopts.format = SaveDocumentType.JPEG;

jpgopts.includeProfile = true;

jpgopts.quality = 80;

// create the pdf-name;

if (theSuffix.length > 0) {

var aSuffix = "_" + theSuffix

}

else {

var aSuffix = ""

};

// create a flattened copy;

var theCopy = myDocument.duplicate("thecopy", true);

// do the operation;

for (var m = theLayerSelection.length - 1; m >= 0; m--) {

app.activeDocument = myDocument;

var theLayer = theLayerSets[theLayerSelection];

if (theNumbering == true) {

theNumber = bufferNumberWithZeros((Number (theNumber) + 1), 2);

theNumberString =  "_" + theNumber

};

else {

theNumberString = ""

};

// get the layername for the pdf-name;

if (theLayerNameAdd == true) {

var aLayerName = "_" + theLayer.name.replace("/", "_")

}

else {

var aLayerName = ""

}

// transfer layerset over to the copy;

theLayer.duplicate (theCopy, ElementPlacement.PLACEATBEGINNING);

app.activeDocument = theCopy;

// hide the llast added layer;

theCopy.layers[1].visible = false;

theCopy.exportDocument(new File(theDestination+"/"+myDocName+aSuffix+aLayerName+theNumberString+".jpg"), ExportType.SAVEFORWEB, jpgopts );

};

theCopy.close(SaveOptions.DONOTSAVECHANGES);

}

};

else {alert ("no document open")};

////////////////////////////////////

////// buffer number with zeros //////

function bufferNumberWithZeros (number, places) {

var theNumberString = String(number);

for (var o = 0; o < (places - String(number).length); o++) {

theNumberString = String("0" + theNumberString)

};

return theNumberString

};

////// function collect all layersets //////

function collectLayerSets (theParent) {

if (!allLayerSets) {

var allLayerSets = new Array}

else {};

for (var m = theParent.layers.length - 1; m >= 0;m--) {

var theLayer = theParent.layers;

// apply the function to layersets;

if (theLayer.typename == "ArtLayer") {

// allLayerSets = allLayerSets.concat(theLayer)

}

else {

// this line includes the layer groups;

allLayerSets = allLayerSets.concat(theLayer);

allLayerSets = allLayerSets.concat(collectLayerSets(theLayer))

}

}

return allLayerSets

};

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 12, 2009 0
Guru ,
Sep 13, 2009

Copy link to clipboard

Copied

mazmax wrote:

  • Use ExportOptionsSaveForWeb with JPEG 80% but it's giving me just 1 file name "filename-#0.jpg" with the contents of the lowest group

I have seen others report this filename issue when scripting SFW on MacOS. I think the fix is to go into make sure your Filename Compatibility is set to Unix in the Saving Files section of the Output Settings in the flyout menu of the SFW dialog.

Another option is to let SFW do it's thing and have the script rename the file to the desired name after the export.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 13, 2009 0
New Here ,
Sep 14, 2009

Copy link to clipboard

Copied

Yep you're right Mike!

I added jpgopts.byteOrder = ByteOrder.MACOS; and it works fine

Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 14, 2009 0
Explorer ,
Jun 08, 2010

Copy link to clipboard

Copied

Groups to .png is what I*m searching for, too.

Any ideas? Anyone?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2010 0
Valorous Hero ,
Jun 08, 2010

Copy link to clipboard

Copied

You could try this..


#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets.name);
dupLayers();
var saveFile= File(oldPath +"/"+doc.layerSets
.name +".png");
SavePNG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
}
main()...

function dupLayers() {
    var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm  '), activeDocument.activeLayer.name );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
};
function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    pngSaveOptions.embedColorProfile = true;
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    pngSaveOptions.matte = MatteType.NONE;
pngSaveOptions.PNG8 = false;
    pngSaveOptions.transparency = true;
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2010 0
New Here ,
Jun 10, 2010

Copy link to clipboard

Copied

Great script Paul!

I've added

     activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true);

before

     activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);

so the PNG files are trimmed before saving.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2010 0
New Here ,
Sep 29, 2010

Copy link to clipboard

Copied

Paul, This looks like a life saver script to me, but I am having a problem.

When I run it, it asks to save each group/file as a PSD.

I am an old time programmer, so I get the logic, but I don't know any of the syntax of photoshop scripting.

If i did I would try to sort this out myself.

Is there some overriding setting in preferences I need to change that won't just allow the script to save the group as a PNG (without my interaction) as the script seems to be telling it to do?

Thank you SO much.


Ed

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 29, 2010 0
Valorous Hero ,
Sep 29, 2010

Copy link to clipboard

Copied

There were a fewmistakes in that code, could you please try this now...


#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets.name);
dupLayers();
activeDocument.mergeVisibleLayers();
activeDocument.trim(TrimType.TRANSPARENT,true...
.name +".png");
SavePNG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
}
main()...










function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 29, 2010 1