Layer Comps to files

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

iMatt

Layer Comps to files

Post by iMatt »

Hi There-
I've just started to integrate layer comps into my workflow, and I've hit a snag. I have several versions of a document saved into the layer comps, and currently when I run export layer comps as files I have the option to export the files as TIFFs, but only layered TIFFs, and I'm required to deliver flattened Tiffs without paths or alpha channels, it would be most convenient if all of those options could exist in the export layer comps to files dialogue. Additionally, the export layer comps as files script also exports the last document state, which I don't need usually, so it would be great if I had the option to turn that off. This would save me from having to reopen all of the files and run additional actions to flatten the images, remove the alpha channels, and delete the paths, and would cut down on saving time because it would avoid saving an additional file that I just throw away. In addition to all of this my file names get rather long, because of naming conventions imposed on me, and as a result Photoshop's tendency to trunkate the file name when saving as a copy gets really annoying, so I tend to stay away from those options in the save as dialogue.

I found this code that xbytor posted on the Adobe forums, but it doesn't totally satisfy what I'm looking for. Alternatively, if I had the option to run the actions that I want to before the script saves the separate layer comps–similar to image processor–that would be great too.
Code: Select all// for getting  tiffs of layercomps;


#target photoshop


var myDocument = app.activeDocument;


// getting the name and location, thanks to xbytor;


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


var docPath = myDocument.path;


// tiff options;


   tifOpts = new TiffSaveOptions();


   tifOpts.embedColorProfile = true;


   tifOpts.imageCompression = TIFFEncoding.TIFFLZW;


   tifOpts.alphaChannels = false;


   tifOpts.byteOrder = ByteOrder.MACOS ;


   tifOpts.layers = true;


// create the versions;


for (var m = 0; m < myDocument.layerComps.length; m++) {


// apply the layer comp;


   myDocument.layerComps[m].apply();


   var theLayerCompName = myDocument.layerComps[m].name;


// duplicate the image;


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


// save the tiff;


   thecopy.saveAs((new File(docPath+"/"+basename+"_E"+theLayerCompName+"_S01.tif")),tifOpts,true);


   thecopy.close(SaveOptions.DONOTSAVECHANGES);


   app.activeDocument = myDocument;


   };


Thanks for the help.