The DAM Forum
Welcome, Guest. Please login or register.
May 23, 2013, 05:36:22 PM

Login with username, password and session length
Search:     Advanced search
Jan 9, 2012
John Beardsworth's new Lightroom site
Lightroom Solutions
27960 Posts in 5113 Topics by 2914 Members
Latest Member: imthedamstar
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Scripting
| | |-+  raw to psd script -- does anyone have one?
« previous next »
Pages: [1] Print
Author Topic: raw to psd script -- does anyone have one?  (Read 5734 times)
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« on: February 13, 2008, 10:08:40 AM »

Hello,

I have an xMedia catalog with my (Nikon) raw files (.NEF).  Once I've sorted the raw images from a shoot to select the images which need post-processing, I want to create a photoshop file (.PSD) for each of the .NEF files, such that the raw file is a smart object layer in a .PSD document (named the same as the .NEF, but with a .PSD extension) that matches the dimensions of the raw file. 

Does anyone have a script that does this?  I know lots of Photoshop users are using the smart object layer technique for non-destructive editing, but it seems like it would be too much work to have to create the smart object layer individually for each of the tens of files from a shoot that need post-processing.  If you're not using a script, what's your technique for creating the derivative file from the raw file?

Thanks,
Matt
Logged
johnbeardy
Administrator
Hero Member
*****
Posts: 1813


View Profile WWW
« Reply #1 on: February 13, 2008, 10:34:59 AM »

Select multiple files in xMedia, then choose Open with Photoshop, hold down Shift in the Adobe Camera Raw dialog - the Open Images button changes to Open Objects.

I wrote a script for Windows but it wasn't very reliable.

John
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #2 on: February 13, 2008, 11:04:08 AM »

Hello John,

I should have stated that I'm still using PS CS2.  Does your technique work only for CS3, or for CS2 too?  (Depending on your answer then maybe that will be the tipping point for my finally upgrading to CS3.)

I did some Googling and found this helpful page from Ben Willmore:

http://whereisben.blogs.com/whereisben/2005/08/photoshop_insig.html

Thanks,
Matt
Logged
johnbeardy
Administrator
Hero Member
*****
Posts: 1813


View Profile WWW
« Reply #3 on: February 13, 2008, 11:09:28 AM »

CS3. I think CS3 is a much more interesting upgrade than CS2 was. Smart filters will definitely appeal to you, but I'd also point to the super work Adobe did on the black and white adjustment, and the Photomerge tool is excellent.

John
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #4 on: February 13, 2008, 12:42:59 PM »

John: thanks for the info about CS3.

I did have a related question about using raw files as a smart object layer.  I had created the PSD file from the raw NEF, giving the PSD doc the original dimensions that came out of the camera.  I then edited the smart object layer, which brought up the Camera Raw dialog box, and performed a crop of the image.  My question is, what are the dimensions of the resulting PSD image?  Is it the original dimensions that came out of camera, or is it the (smaller) cropped dimensions?

As far as I can tell, the PSD file still has the original, uncropped dimensions.  If so, then does this mean that the smart object layer (containing the raw image) has been automatically resampled (from smaller to larger)?  Is there a way to crop the smart object layer and propagate those new dimensions to the resulting PSD image, such that the resampling can be avoided?

Or is it the case that when you use a raw file as a smart object layer, you're supposed to have done the cropping/leveling beforehand, and you're supposed to create the PSD doc using the cropped dimensions directly?

Thanks,
Matt
Logged
johnbeardy
Administrator
Hero Member
*****
Posts: 1813


View Profile WWW
« Reply #5 on: February 13, 2008, 01:18:22 PM »

The resulting image is the size to which you crop it down in Photoshop proper, but the full raw data is still there, so you can always use Image > Reveal All to get it all back. If you're using SO's, I don't see an advantage to cropping in ACR.

John
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #6 on: February 13, 2008, 01:46:22 PM »

The resulting image is the size to which you crop it down in Photoshop proper, but the full raw data is still there, so you can always use
Image -> Reveal All to get it all back. If you're using SO's, I don't see an advantage to cropping in ACR.

So how would you crop, then?  Using Image->Crop, or some other method?  (Perhaps there is a way to create a crop as a layer.)

Actually, I would prefer to use any cropping technique that does not modify the sidecar (.xmp) files (or the Camera Raw database).  I prefer to archive the raw files as quickly as possible, which I can do once I've entered the metadata.  But I noticed last night that using ACR (via the smart object layer) to crop had the effect of also modifying the .xmp file.  But this breaks my backup scheme, since I have to remember to re-backup my archive.

I would certainly prefer to keep changes to a derivative file (.PSD) localized to the derivative file itself.  If you're not using ACR to crop, then how to you crop?

Thanks again for the help,
Matt
Logged
peterkrogh
Administrator
Hero Member
*****
Posts: 5682


View Profile
« Reply #7 on: February 19, 2008, 10:19:03 AM »

Matt,
Out of curiosity, why are you using Smart Objects?
Peter
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #8 on: February 19, 2008, 10:57:59 AM »

Out of curiosity, why are you using Smart Objects?

But why not use Smart Objects?  (Didn't I just read your paper about non-descructive editing?)  I thought that's what I was supposed to do!  I thought that if I imported the raw file as a Smart Object layer, then I'd be able to use ACR (via the Smart Object layer) to make base adjustments such as cropping, white balance, capture sharpening, etc.

Note that I tried it again and didn't get any .XMP files, so maybe the ACR adjustments are being stored in the .PSD after all.  I have to practice some more.  (I still don't understand John's earlier comment about "not cropping in ACR if you're using SOs" -- but with Smart Objects, isn't that the whole point?  Maybe it's a terminology issue, and he doesn't consider "SO manipulation" to be the same as "ACR manipulation".)

I'm all for non-destructive editing, but I must say the process for using Smart Objects to create a layer for the original raw file is very painful - at least in PS CS2.  I had hoped someone (either at iView/xMedia or Adobe) would have created a script so that I could request, directly from iView, to place a raw file as a smart object layer in a new photoshop document (that matches the dimensions of the original raw file). 

The closest I found was Ben Willmore's script, but that only works from Bridge (which I don't use much), and then with only a single file at a time.  (Even Ben's script is painful, since I must then manually choose the name of the .PSD file in order to save it.  I wanted a script to automatically name the .PSD the same as the new of the raw file used for the smart object layer.)

Of course, it's very possible I don't know what I'm doing, as I'm still learning Photoshop...
Logged
peterkrogh
Administrator
Hero Member
*****
Posts: 5682


View Profile
« Reply #9 on: February 22, 2008, 06:48:38 AM »

Matt,
I think you're overthinking this, to some degree.

When I go to Photoshop, it's typically because I need to do some pixel editing (or maybe output sharpening, or compositing).  In almost all of those cases, there is no real advantage to bringing in the Raw as a smart object.  The work yu'll be doing to the file requires you to make an un-smart (?) layer to pixel edit.

About the only time I want a Raw smart object in a TIFF is when I need to blend two exposures, and I want to se the masked effect before committing to the exposure of each.

Smart filters are another story.  I find these very useful, but I don't need the image to be a smart Raw file to do this.

And yes, the XMP data will be included in the file without sidecars.  TIFF, JPEG, PSD all have the ability to support any XMP data embedded.

Peter
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #10 on: February 22, 2008, 11:16:46 AM »

When I go to Photoshop, it's typically because I need to do some pixel editing (or maybe output sharpening, or compositing).  In almost all of those cases, there is no real advantage to bringing in the Raw as a smart object.  The work you'll be doing to the file requires you to make an un-smart (?) layer to pixel edit.

OK, that clears things up a bit.  I was probably trying to do what John B wrote here (and which I must have misinterpreted) about non-destructive editing:

http://thedambook.com/smf/index.php?topic=2819.msg15877#msg15877

Thanks
Matt
Logged
peterkrogh
Administrator
Hero Member
*****
Posts: 5682


View Profile
« Reply #11 on: February 23, 2008, 08:33:15 AM »

Matt,
To be totally clear, whenever I make a Master File, I will always work in layers in a non-destructive way. 

All adjustments are done as layers, rather than to a layer itself. 

If I need to do something that can't be done as an adjustment layer (sharpen, shadow/highlight) I'll make a new composite layer to do the work to.

If I'm going to do some selective blurring, I'll generally do it as a smart filter since tht's the kind of thing that might need reworking after being presented to the client.

It's all about figuring out what's the most appropriate way to achieve the non-destructive editing.  I admit that's harder than it should be at the moment.

Peter
Logged
matthewjheaney
Jr. Member
**
Posts: 52


View Profile
« Reply #12 on: March 17, 2008, 11:20:17 AM »

I finally got around to writing a script that does what I wanted.  I first had to teach myself javascript and the bridge/photoshop scripting API, but now that I've done so it wasn't too hard.  Luckily I could use Ben Wilmore's original script for some of the gory parts.  The script compiles cleanly with jslint.

The script creates a document with smart object layer from a (raw) file, and the dimensions of the (PSD) document match the cropped dimensions of the raw file.  There are some idiosyncracies to the approach I've used (you must perform any ACR crop before running the script), but it does what I need it to do, much faster than I would be able to do without automation support.

Cheers,
Matt


//opensmartmjh.jsx
MJH = {};  //play in my own sandbox...

if (BridgeTalk.appName === "bridge") {
   (function () {
      var m, pos;

      m = MenuElement.create(
            "menu",
            "MJH tools",
            "before tools/tranber",  //because I also have Ben's script installed
            "MJH-Tools"); 

      pos = "at the end of " + m.id;

      (function () {  //create smart object layer command
         var c;

         c = MenuElement.create(
               "command",
               "Create Smart Object Layer",
               pos);

         c.onSelect = function() {
            var t, f, bt;
            var s = app.document.selections;

            if (s.length === 0) {
               alert("no doc selected");
               return;
            }

            if (s.length > 1) {
               alert("too many docs selected");
               return;
            }

            t = s[0];

            if (!(t instanceof Thumbnail)) {
               alert("not a thumbnail");
               return;
            }

            if (t.type !== "file") {
               alert("selection is not a file");
               return;
            }

            f = t.spec;

            if (!(f instanceof File)) {
               alert("not a file");
               return;
            }

            BridgeTalk.bringToFront("photoshop");

            bt = new BridgeTalk();
            bt.target = "photoshop";
            bt.body = "MJH.OpenSmart('" + f.absoluteURI + "');";
            bt.send();
         };  //c.onSelect = function()
      })();  //create smart object layer command
     
      //more commands here:
      //(function () {
      //  body here
      //))();

   })();
} else if (BridgeTalk.appName === "photoshop") {
   MJH.OpenSmart = function (uri) {
      var f, smartDoc, newdoc, rulerUnits, w, h, r, dd, smartName, newName;
      var bitsPerChannel, bgLayer, result, si, ni, newFile, newURI;

      f = new File(uri);

      try {
         smartDoc = app.open(f);  //TODO: specify raw options here?
      } catch (e) {
         alert(e);
         return;
      }

      rulerUnits = app.preferences.rulerUnits;
      app.preferences.rulerUnits = Units.PIXELS;

      //TODO:
      //This opens the doc that will later be re-opened as the smart layer.
      //it does not bring up the ACR dialog.  When we later re-open the
      //doc as the smart layer during the place, the ACR dialog *does*
      //open. The issue is that we can't do an ACR crop during the place,
      //since this will mess up the dimensions we derive below. It would
      //be nice if there were a way to eliminate having to open the file
      //simply to determine the (cropped) dimensions, but I haven't
      //figured out how to do that.
      //END TODO.

      w = parseInt(smartDoc.width, 10);
      h = parseInt(smartDoc.height, 10);
      r = smartDoc.resolution;
      bitsPerChannel = smartDoc.bitsPerChannel;
      smartName = smartDoc.name;

      newName = smartName.substr(0, smartName.length - 3) + "PSD";

      dd = app.documents;

      newDoc = dd.add(w, h, r, newName, NewDocumentMode.RGB);
      newDoc.bitsPerChannel = bitsPerChannel; //BitsPerChannelType.SIXTEEN;

      bgLayer = newDoc.activeLayer;

      //from ben wilmore's script:
      //TODO: clean this up

      // Turn off resize during place paste
      (function () {
         var id5 = charIDToTypeID( "setd" );
         var desc3 = new ActionDescriptor();
         var id6 = charIDToTypeID( "null" );
         var ref1 = new ActionReference();
         var id7 = charIDToTypeID( "Prpr" );
         var id8 = charIDToTypeID( "GnrP" );
         ref1.putProperty( id7, id8 );
         var id9 = charIDToTypeID( "capp" );
         var id10 = charIDToTypeID( "Ordn" );
         var id11 = charIDToTypeID( "Trgt" );
         ref1.putEnumerated( id9, id10, id11 );
         desc3.putReference( id6, ref1 );
         var id12 = charIDToTypeID( "T   " );
         var desc4 = new ActionDescriptor();
         var id13 = stringIDToTypeID("resizePastePlace");
         desc4.putBoolean( id13, false );
         var id14 = charIDToTypeID( "GnrP" );
         desc3.putObject( id12, id14, desc4 );
         executeAction( id5, desc3, DialogModes.NO);
      })();

      //Place16bitFile
      result = (function () {
         var id18 = charIDToTypeID( "Plc " );
         var desc3 = new ActionDescriptor();
         var id19 = charIDToTypeID( "null" );
         desc3.putPath( id19, f);  //here's where we name the smart object file
         var id20 = charIDToTypeID( "FTcs" );
         var id21 = charIDToTypeID( "QCSt" );
         var id22 = charIDToTypeID( "Qcsa" );
         desc3.putEnumerated( id20, id21, id22 ); // not sure what this does
         var id23 = charIDToTypeID( "Ofst" );
         var desc4 = new ActionDescriptor();
         var id24 = charIDToTypeID( "Hrzn" );
         var id25 = charIDToTypeID( "#Pxl" );
         desc4.putUnitDouble( id24, id25, 0.000000 ); // could add that to the call
         var id26 = charIDToTypeID( "Vrtc" );
         var id27 = charIDToTypeID( "#Pxl" );
         desc4.putUnitDouble( id26, id27, 0.000000 ); // and maybe this
         var id28 = charIDToTypeID( "Ofst" );
         desc3.putObject( id23, id28, desc4 );

         try {
            var desc5 = executeAction( id18, desc3, DialogModes.NO );
         } catch (e) {
            if (e.number !== 8007) { //user cancelled
               alert(e);
            }

            return false;  //place failed
         }

         return true;  //place succeeded
      })();

      if (!result) {  //place failed
         newDoc.close(SaveOptions.DONOTSAVECHANGES);
      } else {
         bgLayer.remove();
         newDoc.revealAll();  //?
         
         si = smartDoc.info;
         ni = newDoc.info;

         ni.author = si.author;
         ni.authorPosition = si.authorPosition;
         ni.caption = si.caption;
         ni.city = si.city;
         ni.copyrighted = si.copyrighted;
         ni.copyrightNotice = si.copyrightNotice;
         ni.country = si.country;
         ni.creationDate = si.creationDate;
         ni.headline = si.headline;
         ni.instructions = si.instructions;
         ni.jobName = si.jobName;
         //ni.keywords
         ni.ownerUrl = si.ownerUrl;
         ni.provinceState = si.provinceState;
         ni.source = si.source;
         //ni.supplementalCategories
         ni.title = si.title;
         ni.transmissionReference = si.transmissionReference;
         ni.urgency = si.urgency;

         newURI = f.path + "/" + newDoc.name;  //TODO: better way to do this?

         try {
            newFile = new File(newURI);
            newDoc.saveAs(newFile);
         } catch (saveErr) {
            alert(saveErr);
         }
      }

      smartDoc.close(SaveOptions.DONOTSAVECHANGES);
      f.close();
      app.preferences.rulerUnits = rulerUnits;
   };
}
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!