🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #229

Re: Scripts / Export Layers to Files / Include Background Layer

#229
From: christoph_pfaffenbichler
Date: Sun, 22 Mar 2009 12:21
103 lines
2753 bytes
Adapting that Script might be somewhat difficult as it is pretty bulky.
But if it�s always the topmost layer that�s supposed to stay visible and You know which format You want to save the resulting files to beforehand something much smaller may suffice.
You might try this:


 
#target photoshop; 

var myDocument = app.activeDocument; 

// get the name and location; 

var docName = myDocument.name; 

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

var docPath = myDocument.path; 

// get the artlayers and remove the topmost; 

var allArtLayers = collectLayers(myDocument); 

var theTopmost = allArtLayers.pop(); 

// hide all but the topmost layer; 

for (var n = 0; n < allArtLayers.length; n++ ) { 

   allArtLayers[n].visible = false 

   }; 

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

// show the layer; 

   allArtLayers[m].visible = true; 

// tiff options; 

   tifOpts = new TiffSaveOptions(); 

   tifOpts.embedColorProfile = true; 

   tifOpts.imageCompression = TIFFEncoding.TIFFLZW; 

   tifOpts.alphaChannels = false; 

   tifOpts.byteOrder = ByteOrder.MACOS ; 

   tifOpts.layers = true; 

// duplicate the image; 

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

// save copy; 

   thecopy.saveAs((new File(docPath+"/"+basename+" "+allArtLayers[m].name+".tif")),tifOpts,true); 

   thecopy.close(SaveOptions.DONOTSAVECHANGES); 

// hide the layer again; 

   allArtLayers[m].visible = false 

//that�s it; thanks to xbytor; 

   }; 

////// collect all artlayers ////// 

function collectLayers (theParent) { 

   if (!allArtLayers) { 

      var allArtLayers = new Array}  

   else {}; 

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

      var theLayer = theParent.layers[m]; 

// apply the funtion to layersets; 

      if (theLayer.constructor == ArtLayer) { 

         allArtLayers = allArtLayers.concat(theLayer) 

         } 

      else { 

         allArtLayers = allArtLayers.concat(collectLayers(theLayer)) 

         } 

      }; 

   return allArtLayers 

};
Technical Details
Message-ID: <59b85efb.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b85efb.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,a91c7d18339adb42
X-Google-Attributes: gidf5839,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
From: christoph_pfaffenbichler@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.photoshop.scripting
Subject: Re: Scripts / Export Layers to Files / Include Background Layer
Message-ID: <59b85efb.0@webcrossing.la2eafNXanI>
Date: Sun, 22 Mar 2009 05:21:47 -0700
References: <59b85efb.-1@webcrossing.la2eafNXanI>
Lines: 63
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit