6 Replies Latest reply on Aug 28, 2015 11:15 AM by RESlyder

    Issue opening jpg in Photoshop from Illustrator script

    RESlyder

      Hi all!

       

      I have a javascript file that I use in Illustrator to export a collection of jpegs, and then open those images in Photoshop to be resized. This all worked great in CS5, but when we swapped over to CS6 the images no longer open up in Photoshop. We are using Photoshop 64-bit and Illustrator 64-bit on a Windows 7 system.

       

      Here is the code that worked in CS5:

      //gets the name of the jpg to open
      openFile = new File(this.base_path +"/"+ this.prefix + connector + ex +fileType)
      photoshop.open(File(openFile));
      

       

      Seems like it should be pretty straightforward, not sure what could be causing the issue. I put alerts on either side of the line, and photoshop.open is the line that breaks it. I have tested it with a if (openFile.exists) condition to make sure the file path was correct, and it would throw an alert confirming it existed, but anything after that was cut out. Did the syntax for opening a file in Photoshop change from CS5 to CS6? Any help is appreciated!

        • 1. Re: Issue opening jpg in Photoshop from Illustrator script
          Silly-V Adobe Community Professional

          I didn't know there was a 'photoshop' object in the Illustrator object model, so I $.write'd it to see a large body of javascript which starts with "({versionInfo:{scriptRevision:4, btTargetName:"photoshop", rootVersion:"12.0", displayVersion:"CS5", bridgeTargetVersion:"4", bridgeTarget:"bridge", "... so all I can tell is that something which helps create this object in the scripting environment in CS5 is not there. I'd like to know, myself!
          For the solution, which isn't as straightforward, you'd have to use the bridgetalk object and do the exact same thing as you were able to with simple commands in CS5, instead, with a manageable yet unwieldy procedure or sending an entire script to photoshop as a string, to be executed as script.

           

          Continue a script in Photoshop
          I found this to be a great resource for bridgetalk example.

          • 2. Re: Issue opening jpg in Photoshop from Illustrator script
            CarlosCanto Adobe Community Professional & MVP

            how could you miss it?

             

            Remote function calls

            A limited set of basic functions (the cross-DOM) are common across all message-enabled applications, and

            allow your script to, for example, open or print files in other applications, simply by calling the open or

            print function for that application.

             

            you can read all about it in the Tools Guide

            • 3. Re: Issue opening jpg in Photoshop from Illustrator script
              CarlosCanto Adobe Community Professional & MVP

              I don't have CS6 installed, as you said it's straight forward, it works in CC

               

              the only thing I see is the double file

              openFile = new File(this.base_path.....// this returns a File Object


              so File(openFile)...// is redundant but works somehow.


              it should be

              photoshop.open(openFile);


              other than that I don't see anything wrong with it.


              • 4. Re: Issue opening jpg in Photoshop from Illustrator script
                RESlyder Level 1

                Thanks for the replies! I tried removing the extra File and it didn't seem to make any difference.

                 

                I am already using BridgeTalk to call some photoshop actions, so maybe I can re-write it to include the open action. Thanks!

                • 5. Re: Issue opening jpg in Photoshop from Illustrator script
                  Silly-V Adobe Community Professional

                  I put the photoshop object out of my CS5 into a text file, out of curiosity, what if you try to format it and (#)include it in your script?

                   

                  ({versionInfo:{scriptRevision:4, btTargetName:"photoshop", rootVersion:"12.0", displayVersion:"CS5", bridgeTargetVersion:"4", bridgeTarget:"bridge", bridgeDisplayVersion:"CS5"}, menuItemInfoArray:[], executeScript:(function (script, availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // executeScript. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.executeScript (" + script.toSource () + ");"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM routine 
                  eval (script.toString()); 
                  } 
                  }), open:(function (files, availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.open (" + files.toSource () + ");"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM routine with the files
                  
                  var fileArray = photoshop.ExtractFileArray (files);  
                  
                  for (index = 0; index < fileArray.length; ++index) 
                  { 
                  var file = fileArray[index]; 
                  
                  app.open (file); 
                  } 
                  } 
                  }), openAsNew:(function (availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.openAsNew ();"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM routine 
                  app.documents.add (); 
                  } 
                  }), print:(function (files, availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.print (" + files.toSource () + ");"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM routine with the files
                  
                  var fileArray = photoshop.ExtractFileArray (files);  
                  
                  for (index = 0; index < fileArray.length; ++index) 
                  { 
                  var file = fileArray[index]; 
                  
                  var document = app.open (file); 
                  
                  if (document != undefined) 
                  { 
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  document.print (); 
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  } 
                  }), quit:(function (availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (AvailabilityCheckOptions.kBusyWarn, false); // warn if busy, don't warn if wrong version is running 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.quit ();"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM
                  
                  var quitID = stringIDToTypeID ('quit'); 
                  executeAction (quitID, undefined, DialogModes.NO); 
                  } 
                  }), reveal:(function (file, availabilityCheckOptions) 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.reveal (" + file.toSource () + ");"; 
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // This is Photoshop, so just call our DOM routine with the files
                  
                  // Loop through the open documents looking for the one 
                  // we want to reveal. If it is found, make it the active 
                  // document. 
                  var docNum = app.documents.length - 1; 
                  
                  while (docNum >= 0) 
                  { 
                  var document = app.documents[docNum]; 
                  
                  // If document is a new unsaved document, accessing 
                  // document.fullName results in an error. Comparing 
                  // it to undefined also results in an error, so it 
                  // is in a try-catch instead. 
                  try 
                  { 
                  if (document.fullName.fsName == file.fsName) 
                  { 
                  app.activeDocument = document; 
                  break; 
                  } 
                  } 
                  catch (e) 
                  { 
                  // ignore. 
                  } 
                  
                  --docNum; 
                  } 
                  } 
                  }), invokeBridge:(function (newWindow, maximize, path) 
                  { 
                  // Make sure this can be run, otherwise alert the user (true for UI). 
                  if (!photoshop.correctBridgeIsAvailable (true)) 
                  return; 
                  
                  // We pass this down to ensure the message we create is based 
                  // off of whether Bridge was running before we attempted to 
                  // launch it, not after we attempted to launch it. 
                  var wasRunning = false; 
                  
                  if (BridgeTalk.isRunning (photoshop.versionInfo.bridgeTarget)) 
                  {   
                  wasRunning = true; 
                  }   
                  else   
                  {   
                  // Make sure we attempt to launch it explicitly. send() will 
                  // typically do it, but can get confused and not do it under some 
                  // circumstances, for example if BridgeTalk previously attempted 
                  // to launch the target but the target never finished launching 
                  // for whatever reason (maybe another copy is running on Windows).   
                  BridgeTalk.launch (photoshop.versionInfo.bridgeTarget);   
                  } 
                  
                  // Send an appropriate message to Bridge to tell it what to do. 
                  var bt = photoshop.getInvokeBridgeMessage (newWindow, maximize, path, wasRunning); 
                  
                  bt.send (); 
                  }), launchBridgeInBackground:(function () 
                  { 
                  // Make sure this can be run, don't alert the user if it can't (false for no UI). 
                  if (!photoshop.correctBridgeIsAvailable (false)) 
                  return; 
                  
                  if (!BridgeTalk.isRunning (photoshop.versionInfo.bridgeTarget)) 
                  { 
                  BridgeTalk.launch (photoshop.versionInfo.bridgeTarget, 'background'); 
                  
                  // On Mac we are able to effectively launch Bridge without Photoshop 
                  // losing focus, so all we have to do is launch Bridge. On Windows we 
                  // are not so lucky and must employ some trickery to avoid having 
                  // Bridge take over as the active app. 
                  if ($.os.charAt (0) == 'M') 
                  return; 
                  
                  
                  // Win trickery 
                  
                  // Get the version number of Bridge so we can locate its 
                  // app/user specific startup directory. 
                  var bridgeSpecifier = BridgeTalk.getSpecifier("bridge", photoshop.versionInfo.bridgeTargetVersion); 
                  var bridgeVersion = null; 
                  
                  if (bridgeSpecifier != null) 
                  bridgeVersion = bridgeSpecifier.match (/[0-9\.]+/); 
                  
                  // Define a function that will be run inside of Bridge to make 
                  // Photoshop come to the foreground. This script will be 
                  // written to a temporary startup script and will self-delete 
                  // after run. 
                  var launchBridgeBehindScript = function (bridgeVersion) 
                  { 
                  // On Windows, bringToFront is only effective if the calling app is 
                  // the foreground app, so it can't be called until Bridge has created 
                  // a window. So if necessary, we insert a handler function that 
                  // deletes itself after one execution. 
                  if (app.documents.length > 0) 
                  { 
                  // the document has already been created, so just bring PS to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  return; 
                  } 
                  
                  // define the handler 
                  var bringPSForwardOnceHandler = function (event) 
                  { 
                  // Run on document creation. 
                  if (event.object.constructor.name == 'Document' && event.type == 'create') 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Remove this handler once it has run. 
                  for (var index = 0; index < app.eventHandlers.length; index++) 
                  { 
                  if (app.eventHandlers[index] == this) 
                  { 
                  app.eventHandlers[index] = null; 
                  break; 
                  } 
                  } 
                  } 
                  
                   // Return false so Bridge will keep calling other event handlers. 
                  return { handled: false }; 
                  } 
                  
                  // Install the event handler. 
                  app.eventHandlers.push ({handler: bringPSForwardOnceHandler}); 
                  
                  } // launchBridgeBehindScript  
                  
                  // Send the script defined above to Bridge for it to execute. 
                  var bt = new BridgeTalk; 
                  bt.target = photoshop.versionInfo.bridgeTarget; 
                  bt.body = 'var func = ' + launchBridgeBehindScript.toString () + 'func ("' + bridgeVersion + '");'; 
                  bt.send (); 
                  
                  } // !BridgeTalk.isRunning (photoshop.versionInfo.bridgeTarget) 
                  }), place:(function (file, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  // customize the behavior 
                  availabilityCheckOptions.busyAction = AvailabilityCheckOptions.kBusyWarn; 
                  availabilityCheckOptions.warnBusyText = localize ("$$$/PSBI/Error/PSBusyWarnPlace=Photoshop %1 is currently busy with another task. Please finish that task in Photoshop, open the document you want to place into, and try again.", photoshop.versionInfo.displayVersion); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // open. 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.place (" + file.toSource () + ");";
                  
                  btMessage.send(); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  var fileArray = photoshop.ExtractFileArray (file); 
                  
                  // This is Photoshop, so just call our DOM routine with the files
                  
                  if (app.documents.length > 0) 
                  { 
                  if (fileArray.length > 0) 
                  { 
                  var theFile = fileArray[0]; 
                  
                  // Set up generic placement information. 
                  var offsetID = stringIDToTypeID ('offset'); 
                  var horizID = stringIDToTypeID ('horizontal'); 
                  var vertID = stringIDToTypeID ('vertical'); 
                  var distUnitID = stringIDToTypeID ('distanceUnit'); 
                  
                  var offsetDesc = new ActionDescriptor (); 
                  
                  offsetDesc.putUnitDouble (horizID, distUnitID, 0.000000); 
                  offsetDesc.putUnitDouble (vertID, distUnitID, 0.000000); 
                  
                  var nullID = charIDToTypeID ('null'); 
                  var ftcenterID = stringIDToTypeID ('freeTransformCenterState'); 
                  var quadCenterID = stringIDToTypeID ('quadCenterState'); 
                  var avgID = stringIDToTypeID ('QCSAverage'); 
                  
                  var placeInfoDesc = new ActionDescriptor (); 
                  
                  placeInfoDesc.putEnumerated (ftcenterID, quadCenterID, avgID); 
                  placeInfoDesc.putObject (offsetID, offsetID, offsetDesc); 
                  
                  // Set up the file. 
                  placeInfoDesc.putPath (nullID, theFile); 
                  
                  // Suppress choose file dialog. 
                  var overrideOpenID = stringIDToTypeID ('overrideOpen'); 
                  placeInfoDesc.putBoolean (overrideOpenID, true); 
                  
                  // Force it to record. 
                  var forceRecordKey = stringIDToTypeID ('forceRecording'); 
                  placeInfoDesc.putBoolean (forceRecordKey, true); 
                  
                  // Do the Place. 
                  var placeID = stringIDToTypeID ('placeEvent'); 
                  
                  executeAction (placeID, placeInfoDesc, DialogModes.ALL); 
                  
                  // force deletion of ActionDescriptor now 
                  offsetDesc = null; 
                  placeInfoDesc = null; 
                  $.gc(); 
                  } 
                  
                  if (fileArray.length > 1) 
                  alert (localize ("$$$/PSBI/Place/OnlyFirstFile=Only the first file was placed.")); 
                  } 
                  else 
                  { 
                  for (index = 0; index < fileArray.length; ++index) 
                  { 
                  var file = fileArray[index]; 
                  
                  // Open as a Smart Object 
                  app.open (file, undefined, true); 
                  } 
                  } 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), saveActiveDocumentAsPSBOnDemand:(function( destPath ) 
                  { 
                  var startRulerUnits = app.preferences.rulerUnits; 
                  
                  try 
                  { 
                  var doc = app.activeDocument; 
                  
                  app.preferences.rulerUnits = Units.PIXELS;  
                  if (doc.height.value > 30000 || doc.width.value > 30000) 
                  { 
                  const eventSave  = app.charIDToTypeID('save'); 
                  const keyAs   = app.charIDToTypeID('As  '); 
                  const keyIn   = app.charIDToTypeID('In  '); 
                  const klargeDocumentFormatStr   = app.charIDToTypeID('Pht8'); // NOT defined in PITerminology.h  
                  app.preferences.rulerUnits = startRulerUnits;  
                  var desc = new ActionDescriptor(); 
                  var bigDesc = new ActionDescriptor(); 
                  desc.putObject( keyAs, klargeDocumentFormatStr, bigDesc ); 
                  desc.putPath( keyIn, new File( destPath ) ); 
                  executeAction( eventSave, desc, DialogModes.NO ); 
                  } 
                  else 
                  { 
                  app.preferences.rulerUnits = startRulerUnits;  
                  doc.saveAs( File( destPath ) ); 
                  } 
                  
                  } 
                  catch (error) 
                  { 
                  app.preferences.rulerUnits = startRulerUnits;  
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), noDialogPhotomerge:(function( files ) 
                  { 
                  try 
                  { 
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Photomerge with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.noDialogPhotomerge (" + files.toSource () + ");";
                  
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  var destPath = files.splice(0,1); 
                  var gFilesFromBridge = files;  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strPhotomerge = localize ("$$$/PSBI/Automate/Photomerge/Photoshop/FileName=Photomerge.jsx"); 
                  var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strPhotomerge;  
                  var ipFile = new File (ipFilePath);  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.NO; 
                  
                  if (ipFile.exists) 
                  { 
                  runphotomergeFromScript = true; 
                  $.evalFile( ipFilePath ); 
                  photomerge.createPanorama( files ); 
                  photoshop.saveActiveDocumentAsPSBOnDemand(destPath); 
                  app.activeDocument.close(); 
                  runphotomergeFromScript = false; 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/Photomerge/NotFound=%1 could not be found.", strPhotomerge)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), photomerge:(function (/* Array */ files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Photomerge with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.photomerge (" + files.toSource () + ");";
                  
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  var gFilesFromBridge = files;  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strPhotomerge = localize ("$$$/PSBI/Automate/Photomerge/Photoshop/FileName=Photomerge.jsx"); 
                  var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strPhotomerge;  
                  var ipFile = new File (ipFilePath);  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (ipFile.exists) 
                  { 
                  $.evalFile( ipFilePath ); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/Photomerge/NotFound=%1 could not be found.", strPhotomerge)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  }  
                  }), photomergeFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, true); 
                  
                  if (files.length != 0) 
                  photoshop.photomerge (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), contactSheet:(function (/* Array */ files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Contact Sheet with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.contactSheet (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  photoshop.runActionCommand ('0B71D221-F8CE-11d2-B21B-0008C75B322C', files); 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), contactSheetFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.contactSheet (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }   //----------------------------------------------------------------- // The code below inserts the Contact Sheet menu item into the // Bridge menus. It requires the optional Photoshop ContactSheetII  // plug-in to be manually installed by the user. Uncomment the following // Bridge menu insertion code if you want to invoke such functionality // directly from Bridge. //-----------------------------------------------------------------  /* -------------------------- START ------------------------------- if ((BridgeTalk.appName == "bridge") && (BridgeTalk.appVersion.indexOf (photoshop.versionInfo.bridgeTargetVersion) == 0)) 
                  {
                  
                  // Use temp function to keep vars out of global namespace. 
                  photoshop.tempFunction = function () 
                  { 
                  // Set up the info necessary for inserting this item into the Bridge's menus later. 
                  var menuItemInfo = new Object; 
                  menuItemInfo.text = localize ("$$$/PSBI/Menu/Automate/ContactSheet=Contact Sheet II..."); 
                  menuItemInfo.name = 'ContactSheet'; 
                  menuItemInfo.onSelect = photoshop.contactSheetFromBridge; 
                  
                  photoshop.menuItemInfoArray.push (menuItemInfo); 
                  } 
                  
                  photoshop.tempFunction (); 
                  delete photoshop.tempFunction; 
                  }), picturePackage:(function (/* Array */ files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Picture Package with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.picturePackage (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  photoshop.runActionCommand ('4C1ABF40-DD82-11d2-B20F-0008C75B322C', files); 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), picturePackageFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.picturePackage (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }   //----------------------------------------------------------------- // The code below inserts the PicturePackage menu item into the // Bridge menus. It requires the optional Photoshop WebContactSheetII  // plug-in to be manually installed by the user. Uncomment the following // Bridge menu insertion code if you want to invoke such functionality // directly from Bridge. //-----------------------------------------------------------------  /* -------------------------- START ------------------------------- if ((BridgeTalk.appName == "bridge") && (BridgeTalk.appVersion.indexOf (photoshop.versionInfo.bridgeTargetVersion) == 0)) 
                  { 
                  // Use temp function to keep vars out of global namespace. 
                  photoshop.tempFunction = function () 
                  { 
                  // Set up the info necessary for inserting this item into the Bridge's menus later. 
                  var menuItemInfo = new Object; 
                  menuItemInfo.text = localize ("$$$/PSBI/Menu/Automate/PicturePackage=Picture Package..."); 
                  menuItemInfo.name = 'PicturePackage'; 
                  menuItemInfo.onSelect = photoshop.picturePackageFromBridge; 
                  
                  photoshop.menuItemInfoArray.push (menuItemInfo); 
                  
                  } 
                  
                  photoshop.tempFunction (); 
                  delete photoshop.tempFunction; 
                  }), batch:(function (/* Array */ files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  // Make sure this can be run. 
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Batch with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.batch (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  photoshop.runActionCommand ('batch', files, 
                  localize ("$$$/PSBI/Automate/BatchSettingsFile=Batch via Bridge Settings")); 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), batchFromBridge:(function () 
                  { 
                  try 
                  { 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  // Make sure this can be run. 
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.batch (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), loadFilesIntoStack:(function (files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // LoadFilesIntoStack with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.loadFilesIntoStack (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // Load Files into Stack script will recognize this and use it 
                  var gFilesFromBridge = files; 
                  
                  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); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (ipFile.exists) 
                  { 
                  $.evalFile( ipFilePath ); //
                  alert (localize ("$$$/PSBI/Automate/LoadFiles2Stack/CouldNotOpen=%1 could not be opened.", strFile2Stack)); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/LoadFiles2Stack/NotFound=%1 could not be found.", strFile2Stack)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), loadFilesIntoStackFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.loadFilesIntoStack (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), lensCorrect:(function (files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // MergeToHDR with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.lensCorrect (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // Lens Correction script will recognize this and use it 
                  var gFilesFromBridge = files; 
                  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strLensCorrect = localize ("$$$/private/PSBI/Automate/LensCorrect/Photoshop/FileName=Lens Correct.jsx"); 
                  var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strLensCorrect; 
                  
                  var ipFile = new File (ipFilePath); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (ipFile.exists) 
                  { 
                  $.evalFile( ipFilePath ); //
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/CouldNotOpen=%1 could not be opened.", strMerge2HDR)); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/NotFound=%1 could not be found.", strLensCorrect)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), lensCorrectFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.lensCorrect (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), noDialogMergeToHDR:(function( files ) 
                  { 
                  try 
                  { 
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // MergeToHDR with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.noDialogMergeToHDR (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  // Take the first as the destination 
                  var destPath = files.splice(0,1);  
                  // Merge to HDR script will recognize this and use it 
                  var gFilesFromBridge = files; 
                  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strMerge2HDR = localize ("$$$/PSBI/Automate/MergeToHDR/Photoshop/FileName=Merge To HDR.jsx"); 
                  var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strMerge2HDR; 
                  
                  var ipFile = new File (ipFilePath); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.NO;
                  //??? 
                  
                  if (ipFile.exists) 
                  { 
                  runMergeToHDRFromScript = true; 
                  $.evalFile( ipFilePath ); 
                  mergeToHDR.mergeFilesToHDR( files, true ); 
                  photoshop.saveActiveDocumentAsPSBOnDemand(destPath); 
                  app.activeDocument.close(  ); //
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/CouldNotOpen=%1 could not be opened.", strMerge2HDR)); 
                  runMergeToHDRFromScript = false; 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/NotFound=%1 could not be found.", strMerge2HDR)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), mergeToHDR:(function (files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // MergeToHDR with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.mergeToHDR (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // Merge to HDR script will recognize this and use it 
                  var gFilesFromBridge = files; 
                  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strMerge2HDR = localize ("$$$/PSBI/Automate/MergeToHDR/Photoshop/FileName=Merge To HDR.jsx"); 
                  var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strMerge2HDR; 
                  
                  var ipFile = new File (ipFilePath); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (ipFile.exists) 
                  { 
                  $.evalFile( ipFilePath ); //
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/CouldNotOpen=%1 could not be opened.", strMerge2HDR)); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/NotFound=%1 could not be found.", strMerge2HDR)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), mergeToHDRFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.mergeToHDR (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), imageprocessor:(function (files, availabilityCheckOptions) 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  if (availabilityCheckOptions == null) 
                  availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  if (BridgeTalk.appName != "photoshop") 
                  { 
                  // Bring Photoshop to the foreground. 
                  BridgeTalk.bringToFront (photoshop.versionInfo.btTargetName); 
                  
                  // Create a new BridgeTalk message for Photoshop to invoke 
                  // Image Processor with the selected files 
                  var btMessage = new BridgeTalk; 
                  btMessage.target = photoshop.versionInfo.btTargetName; 
                  btMessage.body = "photoshop.imageprocessor (" + files.toSource () + ");"; 
                  btMessage.send (); 
                  } 
                  else 
                  { 
                  app.bringToFront(); 
                  
                  // Image Processor script will recognize this and use it 
                  var gFilesFromBridge = files; 
                  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strImageProcessor = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/FileName=Image Processor.jsx"); 
                  
                  var ipFile = new File (app.path + "/" + strPresets + "/" + strScripts + "/" + strImageProcessor); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (ipFile.exists) 
                  { 
                  if (ipFile.open ('r')) 
                  { 
                  var script = ipFile.read (); 
                  ipFile.close (); 
                  eval (script); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/ImageProcessor/CouldNotOpen=Image Processor.jsx could not be opened.")); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/ImageProcessor/NotFound=Image Processor.jsx could not be found.")); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), imageprocessorFromBridge:(function () 
                  { 
                  try 
                  { 
                  // Make sure this can be run. 
                  var availabilityCheckOptions = new AvailabilityCheckOptions (); 
                  
                  if (!photoshop.correctPSIsAvailable (availabilityCheckOptions)) 
                  return; 
                  
                  var files = photoshop.getBridgeFileListForAutomateCommand (true, false); 
                  
                  if (files.length != 0) 
                  photoshop.imageprocessor (files, availabilityCheckOptions); 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), launchDeviceCentral:(function (doNewDocument) 
                  { 
                  var result = false; 
                  try 
                  { 
                  var bt = new BridgeTalk; 
                  
                  var dcTarget = "devicecentral"; 
                  
                  if (BridgeTalk.getSpecifier (dcTarget) == null) 
                  { 
                  result = false; 
                  } 
                  else 
                  { 
                  bt.target = dcTarget; 
                  if (doNewDocument) 
                  { 
                  bt.body = "app.activate(); app.newDocument();"; 
                  } 
                  else 
                  { 
                  bt.body = "app.activate(); app.browse();" 
                  }  
                  result = bt.send(); 
                  
                  result = true;
                  // I don't trust the return value from send () 
                  } 
                  } 
                  catch (e) 
                  { 
                  result = false; 
                  } 
                  
                  return result; 
                  }), openFromLightroom:(function (file,
                  // required. file to open 
                  acrDesc,
                  // optional. pass acr descriptor to have PS open file with custom ACR settings 
                  lightroomDocID,
                  // optional. include for notifications on save and close 
                  bridgeTalkID,
                  // required if lightroomDocID is present. Pass sending app's BT id 
                  saveDesc,
                  // optional. pass save desc to have PS use provided format, location, etc for save 
                  dialogMode)
                  // optional. defaults to DisplayDialogs.ERROR. used by M2HDR and Photomerge scripts 
                  { 
                  var result = false; 
                  
                  // use ERROR dialog mode unless otherwise requested. This will show things like 
                  // color profile mismatch and missing font dialogs, 
                  if (dialogMode == null) 
                  dialogMode = DialogModes.ERROR;  
                  try 
                  { 
                  // construct an open descriptor with all of the info provided 
                  var openDesc = new ActionDescriptor(); 
                  
                  // add the file to open 
                  openDesc.putPath (stringIDToTypeID ("target"), file); 
                  
                  // force the open to be recorded if recording is on 
                  openDesc.putBoolean (stringIDToTypeID ("forceRecording"), true); 
                  
                  // Use ACR open parameters descriptor if provided 
                  if (acrDesc != null) 
                  { 
                  openDesc.putObject (stringIDToTypeID("as"), stringIDToTypeID("Adobe Camera Raw"), acrDesc);  
                  } 
                  
                  // include the info needed for PS to track the file and notify LR on save and/or close 
                  if ((lightroomDocID != null) && (bridgeTalkID != null)) 
                  { 
                  openDesc.putString (stringIDToTypeID ("lightroomDocID"), lightroomDocID); 
                  openDesc.putString (stringIDToTypeID ("lightroomBridgetalkID"), bridgeTalkID); 
                  } 
                  
                  // Use save desriptor if provided. At minimum, should include 'as' (format) and 
                  // 'in' (save location) entries as well as any sub-entries to the format object 
                  // that are required to keep the options dialog from showing for the format. 
                  if (saveDesc != null) 
                  { 
                  openDesc.putObject (stringIDToTypeID ('lightroomSaveParams'), stringIDToTypeID ('save'), saveDesc);
                  
                  } 
                  
                  // open the file and return the result (Photomerge and Merge To HDR need the value) 
                  result = app.executeAction (stringIDToTypeID( "open" ), openDesc, dialogMode); 
                  } 
                  catch (error) 
                  { 
                  if (dialogMode != DialogModes.NO) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  } 
                  
                  return result; 
                  }), mergeToHDRFromLightroom:(function (
                  files, 
                  acrDescs, 
                  lightroomDocID, 
                  bridgeTalkID, 
                  saveDesc) 
                  { 
                  try 
                  { 
                  // Merge to HDR script will recognize these and use them 
                  var gFilesFromLightroom = files; 
                  var gOpenParamsFromLightroom = acrDescs; 
                  var gLightroomDocID = lightroomDocID; 
                  var gBridgeTalkID = bridgeTalkID; 
                  var gLightroomSaveParams = saveDesc;  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strMerge2HDR = localize ("$$$/PSBI/Automate/MergeToHDR/Photoshop/FileName=Merge To HDR.jsx"); 
                  var scriptFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strMerge2HDR; 
                  
                  var scriptFile = new File (scriptFilePath); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (scriptFile.exists) 
                  { 
                  $.evalFile( scriptFilePath ); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/NotFound=%1 could not be found.", strMerge2HDR));  
                  displayDialogs = rememberDialogModes; 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), openAsLayersFromLightroom:(function ( files, 
                   acrDescs, 
                   lightroomDocID, 
                   bridgeTalkID, 
                   saveDesc) 
                  { 
                  try 
                  { 
                  // OpenAsLayers for lightroom 
                  var gFilesFromLightroom = files; 
                  var gOpenParamsFromLightroom = acrDescs; 
                  var gLightroomDocID = lightroomDocID; 
                  var gBridgeTalkID = bridgeTalkID; 
                  var gLightroomSaveParams = saveDesc;  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strOpenAsLayers = "Load Files into Stack.jsx"; 
                  var scriptFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strOpenAsLayers; 
                  
                  var scriptFile = new File (scriptFilePath); 
                  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (scriptFile.exists) 
                  { 
                  $.evalFile( scriptFilePath ); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/MergeToHDR/NotFound=%1 could not be found.", strOpenAsLayers));  
                  displayDialogs = rememberDialogModes; 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), photomergeFromLightroom:(function (
                  files, 
                  acrDescs, 
                  lightroomDocID, 
                  bridgeTalkID, 
                  saveDesc) 
                  { 
                  try 
                  { 
                  //  Photomerge script will recognize these and use them 
                  var gFilesFromLightroom = files; 
                  var gOpenParamsFromLightroom = acrDescs; 
                  var gLightroomDocID = lightroomDocID; 
                  var gBridgeTalkID = bridgeTalkID; 
                  var gLightroomSaveParams = saveDesc;  
                  var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); 
                  var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); 
                  var strPhotomerge = localize ("$$$/PSBI/Automate/Photomerge/Photoshop/FileName=Photomerge.jsx"); 
                  var scriptFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strPhotomerge;  
                  var scriptFile = new File (scriptFilePath);  
                  var rememberDialogModes = displayDialogs; 
                  displayDialogs = DialogModes.ALL; 
                  
                  if (scriptFile.exists) 
                  { 
                  $.evalFile( scriptFilePath ); 
                  } 
                  else 
                  alert (localize ("$$$/PSBI/Automate/Photomerge/NotFound=%1 could not be found.", strPhotomerge)); 
                  
                  displayDialogs = rememberDialogModes; 
                  } 
                  catch (error) 
                  { 
                  if (error.number != 8007) // Don't report user cancelled errors. 
                  alert (error); 
                  } 
                  }), notifyLightroomDocSaved:(function (bridgeTalkID, lightroomDocID, path) 
                  { 
                  if (BridgeTalk.isRunning (bridgeTalkID)) 
                  { 
                  // Create a new BridgeTalk message to notify Lightroom with 
                  var msg = new BridgeTalk; 
                  
                  // use the BT id that was initially provided by LR 
                  msg.target = bridgeTalkID; 
                  
                  // set a custom message type so that the message body does not get translated 
                  // in preperation for evaluation as JavaScript 
                  msg.type = 'PsXmlNotification'; 
                  
                  // Create a File object and pull fsName out of it so that we end up with a POSIX style path on the Mac. 
                  var file = new File (path); 
                  
                  // retrieve full path in URI notation: absolute, platform-independent, and escaped 
                  var preparedPath = file.toString (); 
                  
                  // Get the substance of the notification 
                  msg.body = photoshop.createLightroomNotificationXML (
                  'FileSaved', 
                  lightroomDocID, 
                  preparedPath); 
                  
                  msg.send(); 
                  } 
                  }), notifyLightroomDocClosed:(function (bridgeTalkID, lightroomDocID) 
                  {
                  
                  if (BridgeTalk.isRunning (bridgeTalkID)) 
                  { 
                  // Create a new BridgeTalk message to notify Lightroom with 
                  var msg = new BridgeTalk; 
                  
                  // use the BT id that was initially provided by LR 
                  msg.target = bridgeTalkID; 
                  
                  // set a custom message type so that the message body does not get translated 
                  // in preperation for evaluation as JavaScript 
                  msg.type = 'PsXmlNotification'; 
                  
                  // Get the substance of the notification 
                  msg.body = photoshop.createLightroomNotificationXML (
                  'FileClosed', 
                  lightroomDocID);
                  
                  
                  msg.send(); 
                  } 
                  }), thumbnailArrayToFileArray:(function (/* array of thumbnails */ thumbnails, resolveAliases, requireTwoFiles) 
                  { 
                  var thumbsArray = new Array (); 
                  var filesArray = new Array (); 
                  
                  var foundFolder = false; 
                  
                  for (var index = 0; index < thumbnails.length; index++ ) 
                  { 
                  // Don't add containers to the list, but note if any were found. 
                  if (thumbnails[index].container) 
                  foundFolder = true; 
                  else 
                  thumbsArray.push (thumbnails[index]); 
                  } 
                  
                  if (thumbsArray.length == 0) 
                  { 
                  if (foundFolder) 
                  Window.alert (localize ("$$$/PSBI/Automate/FoldersNotAllowed=Folders cannot be used for this command.")); 
                  else 
                  Window.alert (localize ("$$$/PSBI/Automate/NoFiles=There are no files to process.")); 
                  } 
                  else if (requireTwoFiles && (thumbsArray.length == 1)) 
                  { 
                  Window.alert (localize ("$$$/PSBI/Automate/MoreThanOneRequired=This command requires two or more files.")); 
                  } 
                  else 
                  { 
                  // We have adequate files, now acquire them (make sure VC files have 
                  // a local replica) and then grab the file specs. 
                  app.acquirePhysicalFiles (thumbsArray); 
                  
                  var foundAlias = false; 
                  
                  for (var index = 0; index < thumbsArray.length; index++ ) 
                  { 
                  if (thumbsArray[index].spec != undefined) 
                  { 
                  var file = thumbsArray[index].spec; 
                  
                  if (resolveAliases && file.alias) 
                  { 
                  foundAlias = true; 
                  
                  file = photoshop.resolveFileIfAlias (file); 
                  } 
                  
                  if (file != null) 
                  filesArray.push (file); 
                  } 
                  } 
                  
                  // The only way filesArray.length should be zero here is if an alias could not be resolved. 
                  // or acquire failed for some reason. 
                  if (filesArray.length == 0) 
                  Window.alert (localize ("$$$/PSBI/Automate/AliasNotResolved=The alias(es) could not be resolved and there are no other files to process.")); 
                  } 
                  
                  return filesArray; 
                  }), getBridgeFileListForAutomateCommand:(function (resolveAliases, requireTwoFiles) 
                  {
                  
                  var files = new Array; 
                  var warnNoFiles = false; 
                  
                  if ((app.document != undefined) && (app.document.thumbnail != undefined)) 
                  { 
                  if (app.document.selectionLength > 0) 
                  { 
                  files = photoshop.thumbnailArrayToFileArray (app.document.selections, resolveAliases, requireTwoFiles); 
                  } 
                  else if (app.document.visibleThumbnails.length > 0) 
                  { 
                  files = photoshop.thumbnailArrayToFileArray (app.document.visibleThumbnails, resolveAliases, requireTwoFiles); 
                  } 
                  else 
                  warnNoFiles = true; 
                  } 
                  else 
                  warnNoFiles = true; 
                  
                  if (warnNoFiles) 
                  Window.alert (localize ("$$$/PSBI/Automate/NoFiles=There are no files to process.")); 
                  
                  return files; 
                  }), ExtractFileArray:(function (files) 
                  { 
                  var fileArray = new Array; 
                  
                  // If it isn't an array, make it a length one array. 
                  if (!(files instanceof Array)) 
                  files = new Array (files); 
                  
                  // Turn each item in the array into a File, or remove it. 
                  for (index = 0; index < files.length; ++index) 
                  { 
                  var file = files[index]; 
                  
                  if (file instanceof File) 
                  fileArray.push (file); 
                  else if (typeof file == 'string') 
                  fileArray.push (File (file)); 
                  else 
                  { 
                  // do nothing 
                  } 
                  } 
                  
                  return fileArray; 
                  }), runActionCommand:(function (eventString, 
                  files, 
                  settingsFileName) 
                  { 
                  var eventDesc = null; 
                  
                  // Read in the old settings, if asked. 
                  if (settingsFileName != null) 
                  eventDesc = photoshop.readDescriptor (settingsFileName); 
                  
                  // If this is the first time we've run, there won't be a settings 
                  // file, so create a new blank descriptor. 
                  if (eventDesc == null) 
                  eventDesc = new ActionDescriptor (); 
                  
                  if (files != null) 
                  { 
                  // Create an action list with the provided files and add them 
                  // to the descriptor, overriding any previous ones that might 
                  // have been there. 
                  var filesListKey = stringIDToTypeID ('filesList'); 
                  var filesList = new ActionList (); 
                  
                  for (var index = 0; index < files.length; index++) 
                  filesList.putPath (files[index]); 
                  
                  eventDesc.putList (filesListKey, filesList); 
                  
                  filesList = null; // garbage collect this below 
                  } 
                  
                  // Force it to record. 
                  var forceRecordKey = stringIDToTypeID ('forceRecording'); 
                  eventDesc.putBoolean (forceRecordKey, true); 
                  
                  // Run the action. 
                  var eventKey = stringIDToTypeID (eventString); 
                  var resultDesc = executeAction (eventKey, eventDesc, DialogModes.ALL); 
                  
                  // Don't record the action for Batch 
                  if (eventString == 'batch') 
                  resultDesc.erase (stringIDToTypeID ('using')); 
                  
                  // Save the descriptor for next time, if asked. 
                  if (settingsFileName != null) 
                  photoshop.saveDescriptor (settingsFileName, resultDesc); 
                  
                  // force deletion of descriptor and list now 
                  eventDesc = null; 
                  $.gc(); 
                  }), saveDescriptor:(function (name, descriptor) 
                  { 
                  // try-catch this routine so if something goes terribly wrong 
                  // we can still run the command. 
                  try 
                  { 
                  if ((descriptor == null) || (descriptor.count == 0)) 
                  return; 
                  
                  var folder = photoshop.getActionCmdSettingsFolder (); 
                  
                  if (!folder.exists && !folder.create ()) 
                  return; 
                  
                  var stream = descriptor.toStream (); 
                  
                  var file = new File (folder.fsName + "/" + name + '.psp'); 
                  
                  if (file.open ('w')) 
                  { 
                  file.encoding = 'BINARY'; 
                  file.write (stream); 
                  file.close (); 
                  } 
                  } 
                  catch (e) 
                  { 
                  return null; 
                  } 
                  }), readDescriptor:(function (name) 
                  { 
                  // try-catch this routine so if something goes terribly wrong 
                  // we can still run the command. 
                  try 
                  { 
                  var folder = photoshop.getActionCmdSettingsFolder (); 
                  
                  var file = new File (folder.fsName + "/" + name + '.psp'); 
                  
                  if (!file.exists) 
                  return null; 
                  
                  if (!file.open ('r')) 
                  return null; 
                  
                  file.encoding = 'BINARY'; 
                  var stream = file.read (file.length); 
                  file.close (); 
                  
                  var descriptor = new ActionDescriptor (); 
                  descriptor.fromStream (stream); 
                  
                  return descriptor; 
                  } 
                  catch (e) 
                  { 
                  return null; 
                  } 
                  }), getActionCmdSettingsFolder:(function () 
                  { 
                  var settingsFolder = new Folder (app.preferencesFolder); 
                  
                  if (!settingsFolder.exists) 
                  settingsFolder.create (); 
                  
                  return settingsFolder; 
                  }), getInvokeBridgeMessage:(function (newWindow, maximize, path, wasRunning) 
                  { 
                  var bt = new BridgeTalk; 
                  bt.target = photoshop.versionInfo.bridgeTarget; 
                  
                  // If there is no path, we want to pass nothing to Bridge's routines, 
                  // not an empty File object. 
                  var file = ''; 
                  
                  // toSource is our friend. The 'path' string may have quotes (single or double) 
                  // in it that start messing things up if we want to use it as part of a bigger 
                  // string (in particular part of a BridgeTalk message body); specifically, string 
                  // literals can get terminated early leading to syntax errors. So, we create 
                  // a File object out of it and call toSource on the File object to get back a 
                  // string that can be used as part of a larger string (nasty characters like 
                  // quotes will be replaced with URL friendly equivalents). 
                  // encodeURI does us one better in making sure some additional characters pass 
                  // across the wire successfully. 
                  if (path != null && path != '') 
                  file = File (encodeURI(path)).toSource ();  
                  if (wasRunning) 
                  { 
                  // Create a function that we can pass across to Bridge in a BridgeTalk message. 
                  // This allows us to write more freely than trying to construct a string with it. 
                  // Comments in this function must be of the /* */ form because toSource() is 
                  // not preserving white space so // comments will kill subsequent lines 
                  var bridgeScript = function (newWindow, maximize, file) 
                  { 
                  if (file != null) 
                  { 
                  if (!newWindow && app.documents.length > 0) 
                  { 
                  /* New location for existing window, make sure existing window comes forward */ 
                  app.document.thumbnail = new Thumbnail (file);  
                  app.document.bringToFront(); 
                  } 
                  else 
                  { 
                  /* 
                  New window with location. 
                  Bring new window to front is required if BR is minimized on Windows 
                  */ 
                  var newDoc = new Document (file); 
                  newDoc.bringToFront(); 
                  } 
                  } 
                  else 
                  { 
                  if (app.documents.length == 0) 
                  { 
                  /* 
                  New window with default location, only occurs on Mac where you can have zero BR windows. 
                  Document constructor requires a parameter 
                  */ 
                  new Document (File());  
                  } 
                  else if (newWindow) 
                  { 
                  /* 
                  New window with location. 
                  Bring new window to front is required if BR is minimized on Windows 
                  */ 
                  var newDoc = new Document (app.document.thumbnail); 
                  newDoc.bringToFront(); 
                  } 
                  else 
                  { 
                  /* Just bring the exist doc forward at it's existing location */ 
                  app.document.bringToFront(); 
                  } 
                  }  
                  /* Maximize if requested */ 
                  if (maximize) 
                  app.document.maximize();  
                  } // bridgeScript  
                  // Turn the function into a string and call it directy with the appropriate parameters 
                  bt.body = bridgeScript.toSource() + "(" + newWindow + ", " + maximize + ", " + file + ")";  
                  } 
                  else 
                  { 
                  // this conflicts with the maximize call when file is empty, so don't do it then 
                  if (file) 
                  bt.body = "app.document.thumbnail = new Thumbnail (" + file + ");"; 
                  
                  if ($.os.charAt (0) == 'W') 
                  { 
                  // On Windows, holding any key down when launching an app makes it 
                  // launch behind the current one. Since we support modifiers when 
                  // invoking bridge, this is problematic. To avoid this unwanted 
                  // behavior, we get Bridge to send a message back to Photoshop with 
                  // the body "BridgeTalk.bringToFront ('bridge')". If a key was held 
                  // down then Photoshp still has focus and the call will bring Bridge 
                  // to the foreground. If a key was not held down, then the call does 
                  // nothing. 
                  bt.body += "var bt = new BridgeTalk;" 
                   + "bt.target = '" + photoshop.versionInfo.btTargetName + "';" 
                   + "bt.body = '" + 'BridgeTalk.bringToFront ("' + photoshop.versionInfo.bridgeTarget + '")' + "';" 
                   + "bt.send ();"; 
                  } 
                  } 
                  
                  if (maximize) 
                  bt.body += "app.document.maximize ();"; 
                  
                  return bt; 
                  }), correctBridgeIsAvailable:(function (showUI) 
                  { 
                  var result = false; 
                  
                  if (BridgeTalk.isRunning (photoshop.versionInfo.bridgeTarget)) 
                  { 
                  // It's running, so it is definitely available! 
                  result = true; 
                  } 
                  else if (BridgeTalk.getSpecifier ('bridge', photoshop.versionInfo.bridgeTargetVersion) == null) 
                  { 
                  if (showUI) 
                  alert (localize ("$$$/PSBI/Error/MatchingBridgeVersionNotInstalled=Bridge %1 was not found on this system. To use this command, please reinstall Bridge %1.", photoshop.versionInfo.bridgeDisplayVersion)); 
                  
                  result = false; 
                  } 
                  else 
                  { 
                  // The target version is installed and should be launchable, unless a different version 
                  // is running, which we cannot reliable detect. Hope that is not the case. 
                  result = true; 
                  } 
                  
                  return result; 
                  }), correctPSIsAvailable:(function (checkOptions) 
                  { 
                  // If no options are passed in, use default ones. 
                  if (checkOptions == null) 
                  { 
                  checkOptions = new AvailabilityCheckOptions (); 
                  } 
                  else 
                  { 
                  if (checkOptions.alreadyUsed == true) 
                  return checkOptions.alreadyUsedReturnValue; 
                  } 
                  
                  var result = false; 
                  
                  // No need to check to see if the correct version is installed because if it 
                  // isn't installed then this script doesn't get loaded, except inside of the  
                  // correct version of Photoshop if it really is installed (and its registration 
                  // with BridgeTalk is broken). 
                  
                  if (BridgeTalk.appName == "photoshop") 
                  { 
                  if (BridgeTalk.appVersion.indexOf (photoshop.versionInfo.rootVersion) == 0) 
                  { 
                  // This script is running in the target version of PS. 
                  result = true; 
                  } 
                  else 
                  { 
                  // We are running inside a different version of PS than what is required. This really 
                  // shouldn't happen because this script shouldn't load in a version other than 
                  // the required version. 
                  if (checkOptions.warnIfUnavailable) 
                  alert (checkOptions.warnInsidePSText); 
                  } 
                  } 
                  else if (BridgeTalk.isRunning (photoshop.versionInfo.btTargetName)) 
                  { 
                  // Above is a quick test to see if it is running. If it is, it can be messaged if necessary. 
                  var status = BridgeTalk.ping (photoshop.versionInfo.btTargetName, "STATUS"); 
                  
                  if (status != "IDLE") 
                  { 
                  if (checkOptions.busyAction == AvailabilityCheckOptions.kBusyWarn) 
                  { 
                  alert (checkOptions.warnBusyText); 
                  result = false; 
                  } 
                  else if (checkOptions.busyAction == AvailabilityCheckOptions.kBusyAsk) 
                  { 
                  result = confirm (checkOptions.askBusyText); 
                  } 
                  else if (checkOptions.busyAction == AvailabilityCheckOptions.kBusyAutoQueue) 
                  result = true; 
                  else
                  // AvailabilityCheckOptions.kBusyAutoCancel 
                  result = false; 
                  } 
                  else 
                  result = true; 
                  } 
                  else 
                  { 
                  // The target version is installed and should be launchable, unless a different version 
                  // is running, which we cannot reliable detect. Hope that is not the case. 
                  result = true; 
                  } 
                  
                  checkOptions.alreadyUsed = true; 
                  checkOptions.alreadyUsedReturnValue = result; 
                  
                  return result; 
                  }), resolveFileIfAlias:(function (file) 
                  { 
                  if (file.alias) 
                  { 
                  try 
                  { 
                  file = file.resolve (); 
                  } 
                  catch (e) 
                  { 
                  file = null; 
                  } 
                  
                  // On Windows, a shorcut may get resolved even if the target file doesn't exist 
                  if ((file != null) && !file.exists) 
                  file = null; 
                  } 
                  
                  return file; 
                  }), createLightroomNotificationXML:(function (message, identifier, path) 
                  { 
                  var xmlString = '<?xml version="1.0" encoding="UTF-8"?>';
                  // processing instructions 
                  xmlString += '\n<PSFileStatusChange version="1.0"'; 
                  xmlString += '\n message="' + message + '"'; 
                  xmlString += '\n identifier="' + identifier + '"'; 
                  
                  if (path != null) 
                  xmlString += '\n path="' + path + '"';  
                  xmlString += ' />' 
                  
                  return xmlString; 
                  })})
                  
                  • 6. Re: Issue opening jpg in Photoshop from Illustrator script
                    RESlyder Level 1

                    I ended up using bridgetalk and opening the images that way. Silly CS6! Seems to be working now! Thanks to you both for your help!