and a file »testEmboss-psd« open and active in Photoshop with a top-level (meaning it is not in a Group) Solid Color Layer with the name »colorLayer«; the Script at the bottom will get me these:
// 2012, use it at your own risk;
// thanks to xbytor;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var documentName = myDocument.name;
var basename = documentName.match(/(.*)\.[^\.]+$/)[1];
// get path;
try {var documentPath = myDocument.path}
catch (e) {var documentPath = "~/Desktop"};
// psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = false;
psdOpts.layers = true;
psdOpts.spotColors = true;
// get file;
if ($.os.search(/windows/i) != -1) {var theFile = File.openDialog ("please select files", "*.txt", false)}
else {var theFile = File.openDialog ("please select files", getFiles, false)};
if (theFile) {
var theText = readPref(theFile);
var theArray = theText.split("\n");
//
try {
var theLayer = myDocument.layers.getByName("colorLayer");
// work through list;
for (var m = 0; m < theArray.length; m++) {
var thisText = theArray.split(";");
alert (thisText.join("\n\n"));
var theName = thisText[0];
editSolidFill (thisText[1], thisText[2], thisText[3], theLayer);
// save psd;
myDocument.saveAs((new File(documentPath+"/"+basename+"_"+theName+".psd")),psdOpts,true);
}
}
catch (e) {};
};
};
////// function to change solid fill layers //////
function editSolidFill (theL, theA, theB, theLayer) {
app.activeDocument.activeLayer = theLayer;
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc5 = new ActionDescriptor();
var idLmnc = charIDToTypeID( "Lmnc" );
desc5.putDouble( idLmnc, theL );
var idA = charIDToTypeID( "A " );
desc5.putDouble( idA, theA );
var idB = charIDToTypeID( "B " );
desc5.putDouble( idB, theB );
var idLbCl = charIDToTypeID( "LbCl" );
desc4.putObject( idClr, idLbCl, desc5 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc3.putObject( idT, idsolidColorLayer, desc4 );
executeAction( idsetd, desc3, DialogModes.NO );
};
////// read prefs file //////
function readPref (thePath) {
if (File(thePath).exists == true) {
var file = File(thePath);
file.open("r");
file.encoding= 'BINARY';
var theText = new String;
for (var m = 0; m < file.length; m ++) {
theText = theText.concat(file.readch());
};
file.close();
return String(theText)
}
};
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
if (theFile.name.match(/\.(txt)$/i)) {
return true
};
};