Skip to main content
Inspiring
March 4, 2012
Question

Tricky problem. Opening RAW with Javascript. White balance problem.

  • March 4, 2012
  • 3 replies
  • 2694 views

Hi all. Hopefully someone can help with this - its a tricky one.

I've been using a javascript to send RAW and DNG files to Photoshop CS5 for automatic processing. The script opens the files directly into PS, apparently bypassing Adobe Camera Raw. It always renders the photos with the ACR default settings which can be set in either ACR on Lightroom. The standard Adobe settings are WB (As Shot), Brightness (+50), Contrast (+25).

My problem is that it ignores any changes I have made to the RAW files in ACR. So if I want to use a custom white balance, its not possible to use the javascript. The script ignores the 'custom' white balance and resets it to 'As Shot'.

I've tried changing the default values in ACR but the options are As Shot, or a set Kelvin preset such as Tungsten, Sunlight etc. Nothing helps.

Is it possible for the script to be mindful of the custom adjustments - especially subtle changes to WB - that I have made in ACR?

The script is below...

var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
      var stackFiles = getStackFiles( stacks );
      if(stackFiles.length> 1){
           var bt = new BridgeTalk;
           bt.target = "photoshop";
           var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
           bt.body = myScript;
           bt.onResult = function( inBT ) {myReturnValue(inBT.body); }
           bt.send(500);
      }
}
function getStackFiles( stack ){
      var files = new Array();
      for( var f = 0; f<stack.thumbnails.length;f++){
           files.push(stack.thumbnails.spec);
      }
      return files;
};
function myReturnValue(str){
      res = str;
}
function psRemote(stackFiles){
      var loadLayersFromScript = true;
      var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
      var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");
      var strFile2Stack = "Load Files into Stack.jsx";
      var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack;
      var ipFile = new File (ipFilePath);
      $.evalFile( ipFile );
      loadLayers.intoStack(stackFiles);
      app.doAction ('My Action');
      var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
      app.activeDocument.saveAs(saveFile);
      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

This topic has been closed for replies.

3 replies

Inspiring
March 5, 2012

Thanks for your help. This post should really be in the Photoshop Scripting forum because it regards Load Files into Stacks.jsx. I've moved it to http://forums.adobe.com/thread/970758

Paul Riggott
Inspiring
March 5, 2012

You could stack your own files IE:...

var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
      var stackFiles = getStackFiles( stacks );
      if(stackFiles.length> 1){
           var bt = new BridgeTalk;
           bt.target = "photoshop";
           var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
           bt.body = myScript;
           bt.send(5);
      }
}
function getStackFiles( stack ){
      var files = new Array();
      for( var f = 0; f<stack.thumbnails.length;f++){
           files.push(stack.thumbnails.spec);
      }
      return files;
};

function psRemote(stackFiles){
app.bringToFront();
var thisDoc = open(File(stackFiles[0]));
var Name = decodeURI(app.activeDocument.name).slice(0,-4);
thisDoc.layers[0].name = decodeURI(Name);
for(var a = 1;a<stackFiles.length;a++){
    open(File(stackFiles));
    Name = decodeURI(app.activeDocument.name).slice(0,-4);
    activeDocument.activeLayer.duplicate(thisDoc);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    thisDoc.layers[0].name = Name;
    }
      var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
      app.activeDocument.saveAs(saveFile);
      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}


arwen morgenstern
Known Participant
October 9, 2013

Paul,

this script do perfectly what i need... But unfortunately not in Bridge CS6 :-(

I use Windows7 64 and CS6. When I run the script from the Extended Script Toolkit, everything works great.

Then I saved the script in the Bridge folder "startup scripts". At the start of Bridge I get the following error message:

"Error in C: \ Users \ ... \ AppData \ Roaming \ Adobe \ Bridge CS6 \ Startup
Scripts \ Stack Batch.jsx
Line 1: var = app.document.stacks stacks;
undefined is not an object "

Bridge and then starts the script is not enabled.

Thanks for any help
-kai

Paul Riggott
Inspiring
March 4, 2012

You also need to correct your action, it requires two parameters...

app.doAction("ActionName","ActionSet");

Inspiring
March 4, 2012

But isn't this script just passing a list of files from Bridge to anther script in Photoshop? My guess would be that you need to look at the file opening options in the 'Load Files into Stack.jsx'