🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #124

Re: Javascript template for cs4 needed

#124
From: christoph_pfaffenbichler
Date: Fri, 13 Mar 2009 06:57
83 lines
2573 bytes
Provided none of the layers reside in a Layer Set, which would make things a bit more complicated, You could give this a try (�scene� and �subject� both in lower case though, You can change that easily in the Script):


 
#target photoshop 

var myDocument = app.activeDocument; 

var docName = myDocument.name; 

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

var docPath = myDocument.path; 

var jpgOptions = new JPEGSaveOptions(); 

jpgOptions.embedProfile = true; 

jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE; 

jpgOptions.matte = MatteType.NONE; 

jpgOptions.quality = 10; 

theFolder = Folder.selectDialog("select a folder to save the jpgs to"); 

var theStart = myDocument.activeHistoryState;  

var theScenes = new Array; 

var theSubjects = new Array; 

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

var theLayerName = myDocument.layers[m].name; 

switch (theLayerName.slice(0, 5)) { 

case "scene": theScenes = theScenes.concat (theLayerName); 

break; 

case "subje": theSubjects = theSubjects.concat (theLayerName); 

break} 

}; 

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

myDocument.layers[n].visible = false; 

}; 

for (var o = 0; o < theScenes.length; o++ ) { 

myDocument.layers[ theScenes[o] ].visible = true; 

for (var p = 0; p < theSubjects.length; p++ ) { 

myDocument.layers[ theSubjects[p] ].visible = true; 

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

theCopy.bitsPerChannel = BitsPerChannelType.EIGHT; 

theCopy.saveAs((new File(theFolder+"/"+baseName+"_"+theScenes[o].slice(-1)+"_"+theSubjects[p].slice(-1)+".jpg")),jpgOptions,true); 

theCopy.close(SaveOptions.DONOTSAVECHANGES); 

myDocument.layers[ theSubjects[p] ].visible = false 

}; 

myDocument.layers[ theScenes[o] ].visible = false; 

}; 

myDocument.activeHistoryState = theStart; 

// that�s it; thanks to xbytor; 

// use it at your own risk;
Technical Details
Message-ID: <59b8267f.2@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b8267f.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,6a585aaa247cb861
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: Javascript template for cs4 needed
Message-ID: <59b8267f.2@webcrossing.la2eafNXanI>
Date: Thu, 12 Mar 2009 23:57:04 -0700
References: <59b8267f.-1@webcrossing.la2eafNXanI>
Lines: 47
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit