5 Replies Latest reply: Oct 9, 2013 2:56 AM by arwen morgenstern RSS

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

    OrchidPhoto Community Member

      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[s] );
            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[f].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);
      }

        • 1. Re: Tricky problem. Opening RAW with Javascript. White balance problem.
          Muppet Mark Community Member

          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'

          • 2. Re: Tricky problem. Opening RAW with Javascript. White balance problem.
            Paul Riggott Community Member

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

             

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

            • 3. Re: Tricky problem. Opening RAW with Javascript. White balance problem.
              OrchidPhoto Community Member

              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

              • 4. Re: Tricky problem. Opening RAW with Javascript. White balance problem.
                Paul Riggott Community Member

                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[s] );
                      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[f].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[a]));
                    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);
                } 
                
                
                 
                • 5. Re: Tricky problem. Opening RAW with Javascript. White balance problem.
                  arwen morgenstern

                  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