Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/content/60/9972860/html/smf/Sources/Load.php(225) : runtime-created function on line 3
Writing star ratings to NEFs
The DAM Forum
Welcome, Guest. Please login or register.
July 16, 2019, 12:10:33 PM

Login with username, password and session length
Search:     Advanced search
28033 Posts in 5147 Topics by 2904 Members
Latest Member: kbroch
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Media Pro & Expression Media
| | |-+  Writing star ratings to NEFs
« previous next »
Pages: [1] 2 3 Print
Author Topic: Writing star ratings to NEFs  (Read 36554 times)
cdubea
Newbie
*
Posts: 31



View Profile Email
« on: February 26, 2009, 12:06:23 PM »

It's your friendly pain again.  Thank goodness for this forum!

I've just realized that XM will only write star ratings to XMP files but Nikon products (CaptureNX2 and ViewNX) don't read XMP files   :<

Has some clever soul crafted a script to work around this issue?  Would definitely prefer something which is useable on a Windows box.

thanks all

chris
Logged

matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #1 on: February 26, 2009, 12:32:32 PM »

I've just realized that XM will only write star ratings to XMP files but Nikon products (CaptureNX2 and ViewNX) don't read XMP files.

xMedia will write XMP files if you choose "extract metadata".  However, if you choose "synchronize to original files", then xMedia does modify the NEF file itself.

Has some clever soul crafted a script to work around this issue?  Would definitely prefer something which is useable on a Windows box.

This past weekend I posted an outline of an algorithm for using the DOM (MSXML6) to read and write XMP files.  I used this to allow xMedia and Bridge to communicate.  But you're asking something a little different.  I think you want to use the synchronize feature of xMedia, not the extract metadata feature (but correct me if I'm wrong).

http://thedambook.com/smf/index.php?topic=3914.0

-Matt
Logged
cdubea
Newbie
*
Posts: 31



View Profile Email
« Reply #2 on: February 26, 2009, 12:39:36 PM »

I've just realized that XM will only write star ratings to XMP files but Nikon products (CaptureNX2 and ViewNX) don't read XMP files.

xMedia will write XMP files if you choose "extract metadata".  However, if you choose "synchronize to original files", then xMedia does modify the NEF file itself.


This past weekend I posted an outline of an algorithm for using the DOM (MSXML6) to read and write XMP files.  I used this to allow xMedia and Bridge to communicate.  But you're asking something a little different.  I think you want to use the synchronize feature of xMedia, not the extract metadata feature (but correct me if I'm wrong).

http://thedambook.com/smf/index.php?topic=3914.0

-Matt


xMedia won't write ratings.  This has been confirmed over on the MS forum.  All I'm really looking for at this juncture is the ability to get my star ratings written into my NEFs through xMedia via a script as opposed to another application like Downloader Pro, Photo Mechanics, etc.  If I buy another piece of photo software my wife's head is gonna explode.....

I suspect with a modicum of code and exiftool, I could be there.  But I'm not yet   ;>

thanks,
Logged

matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #3 on: February 26, 2009, 12:51:13 PM »

xMedia won't write ratings.  This has been confirmed over on the MS forum.  All I'm really looking for at this juncture is the ability to get my star ratings written into my NEFs through xMedia via a script as opposed to another application like Downloader Pro, Photo Mechanics, etc.

OK, I understand now.  This should be possible using the NEF SDK.  I have that SDK (you have to write to Nikon and ask for it), but I haven't actually used it yet.  (I originally needed it to read DataTimeDigitized and SubSecTime, but the Microsoft WIC SDK was released around the same time and so it was faster to do it that way.)

You might be able to use the WIC SDK to write ratings into the NEF files, but I haven't tried it.  (I don't like to touch my NEF files, so my workflow is based around XMP.  Hence I have no already-written script that does exactly what you need.)

-Matt
Logged
cdubea
Newbie
*
Posts: 31



View Profile Email
« Reply #4 on: February 26, 2009, 12:57:18 PM »


OK, I understand now.  This should be possible using the NEF SDK.  I have that SDK (you have to write to Nikon and ask for it), but I haven't actually used it yet.  (I originally needed it to read DataTimeDigitized and SubSecTime, but the Microsoft WIC SDK was released around the same time and so it was faster to do it that way.)

You might be able to use the WIC SDK to write ratings into the NEF files, but I haven't tried it.  (I don't like to touch my NEF files, so my workflow is based around XMP.  Hence I have no already-written script that does exactly what you need.)

-Matt


I would be perfectly happy with XMP sidecars, if Nikon's products recognized them.  I've got an old copy of the SDK somewhere, but I think for what I want, I'm gonna focus on exiftool.  I've used it before and it's very robust.

thanks
Logged

peterkrogh
Administrator
Hero Member
*****
Posts: 5682


View Profile Email
« Reply #5 on: February 26, 2009, 04:09:13 PM »

Chris,
I think this is because Nikon is not recognizing XMP data in the file that is being written by EM. (EM uses the Nikon code to write the data).

You could hack it and select all images with one star and write the keyword 1Star into the files.  Nikon software should see that.
Peter
Logged
roberte
Sr. Member
****
Posts: 290


View Profile WWW
« Reply #6 on: February 26, 2009, 07:56:06 PM »

Hi Chris,

Nikon's recent models do use XMP but Nikon have yet to release an SDK or WIC for other vendors to access it. I'd use Color Labels that map to IPTC Urgency in NEFs or consider DNG. Of course that means saying goodbye to Nikon Capture NX.

-- Robert.
Logged

matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #7 on: February 28, 2009, 12:57:05 PM »

All I'm really looking for at this juncture is the ability to get my star ratings written into my NEFs through xMedia via a script as opposed to another application like Downloader Pro, Photo Mechanics, etc.

I was able to successfully use the WIC SDK to read the xmp rating.  The metadata path is:

"/ifd/{ushort=700}/xmp:Rating"

However, I tried using the fast encoder/fast writer to write a new rating value back into the file, and the Commit() operation failed with error WINCODEC_ERR_UNSUPPORTEDOPERATION.  The API docs are telling me that:

"If Commit fails for any reason, you will need to re-encode the image to ensure the new metadata is added to the image."

That makes the solution a little more difficult: I think it means creating a copy of original file with the modified xmp, throwing away the original file, and then renaming the copy to match the original.  (But I could be wrong.)  Perhaps there's a solution that is not based on the fast encoder/fast writer method.

-Matt


Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #8 on: February 28, 2009, 04:50:48 PM »

Perhaps there's a solution that is not based on the fast encoder/fast writer method.

I finally got this to work using the XMP Toolkit SDK.  (Sadly, I had to give up using the WIC SDK, because I'm at the mercy of Nikon's WIC plugin, and that's too many variables for me.)  I memory-mapped the file and scanned for the XMP packet header, and then used the XMP Toolkit to read and then write the rating, and then serialized that back to the stream.

At some point I should probably write a proper NEF file handler and incorporate that into the toolkit, but this method works if all you want to do is manipulate the ratings value.

For now it's just a command-line app, which you can call from a script.  When time permits I'll fold this logic into my COM wrapper (which you can already call from a script).

Let me know if you want any of the code or the binary.

I haven't actually written an xMedia script (yet), but that's relatively simple to do.  If you need help with that part let me know.

-Matt


Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #9 on: March 01, 2009, 09:31:22 PM »

For now it's just a command-line app, which you can call from a script.  When time permits I'll fold this logic into my COM wrapper (which you can already call from a script).

I created a COM server that you can call from a script, so you can say:

Option Explicit
Dim objNEF, intRating

Set objNEF = CreateObject("MJH.NEFHelp")

objNEF.SetRating "XYZ.NEF", 5    'set rating

intRating = objNEF.GetRating("XYZ.NEF")

For now I can only manipulate an XMP packet that is already present in the NEF file.  You'll have to run ViewNX (or CaptureNX, etc) to create the XMP packet, and then use xMedia to read/write the rating value.

-Matt

Logged
cdubea
Newbie
*
Posts: 31



View Profile Email
« Reply #10 on: March 06, 2009, 07:16:45 PM »


I created a COM server that you can call from a script, so you can say:

Option Explicit
Dim objNEF, intRating

Set objNEF = CreateObject("MJH.NEFHelp")

objNEF.SetRating "XYZ.NEF", 5    'set rating

intRating = objNEF.GetRating("XYZ.NEF")

For now I can only manipulate an XMP packet that is already present in the NEF file.  You'll have to run ViewNX (or CaptureNX, etc) to create the XMP packet, and then use xMedia to read/write the rating value.

-Matt



Hi Matt,

This sounds very cool.  Can I get a copy to toy with?

Thanks

Logged

peterkrogh
Administrator
Hero Member
*****
Posts: 5682


View Profile Email
« Reply #11 on: March 07, 2009, 06:14:35 AM »

Just a word here of caution for those considering hacking raw files.  It's possible that you might do something that could break the file, or make some software refuse to open the file in the future. As I recall, PhotoMechanic added XMP notation to proprietary raw at some point, and that made Capture 1 either refuse to open the files, or refuse to display metadata in the files.

I'd be careful about doing this.  Make sure you have two backups.

Peter
Logged
BobSmith
Full Member
***
Posts: 239

bobsmith@mac.com
View Profile WWW
« Reply #12 on: March 07, 2009, 06:38:54 AM »

Yep...  I went through exactly that with Kodak raw files at some point a few years ago.  Iview wrote some relatively benign piece of metadata back to the raw file in a way that rendered the files unrecognizable by Kodak software.  ACR and most other third party processors could still read the files and metadata but Kodak's wouldn't.  To their credit, the Iview team quickly rectified the problem but it was too late for a few key raw files in my collection.  Kodak shooters relied on Kodak software For the same reasons that some Nikon shooters are ardent supporters of Nikon software.  The Kodak software could render files and access features in a way that third party options couldn't.  Completely losing access to Kodak software was a serious loss.  If you go down this path, make sure you keep an untouched version of the original file.

Bob Smith
Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #13 on: March 08, 2009, 09:01:42 AM »

Just a word here of caution for those considering hacking raw files.  It's possible that you might do something that could break the file, or make some software refuse to open the file in the future.

Yes, and that's why I said the tool I wrote will only manipulate XMP packets already embedded in the NEF file.  (It's actually much more conservative than that: it will only read and write the xmp:Rating field.)  As it stands now, the only tool that will embed an XMP packet in a NEF file is ViewNX or CaptureNX.  Once the XMP packet has been embedded, then it's trivial to use the Adobe XMP Toolkit to both find the packet, manipulate the contents of the packet.

At some point I'll probably write something to embed the XMP packet in a the NEF file, but I haven't done that yet.  To do that, I would either have to use the XMPFiles part of the Adobe XMP Toolkit SDK, and force it to treat the NEF as a TIFF, or just write my own custom NEF file handler.  The other alternative is to use the Nikon NEF SDK (which I have, but haven't investigated yet) to embed the XMP packet.

Of course, if you don't want to manipulate NEF files, then you can manipulate the contents of XMP side-car files, either using the Adobe XMP Toolkit (low-level and harder - requires a COM wrapper), or using the DOM (high-level and much easier -- see my others posts in this forum for how to do this).  In fact this is the technique I use myself.  When I move the NEF into my archive, I compute an MD5 and enter that as a custom field of the xMedia catalog.  The NEF itself is never changed.
Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #14 on: March 08, 2009, 09:05:26 AM »

This sounds very cool.  Can I get a copy to toy with?

Yes, I'll get it to you this afternoon.  I'm traveling this weekend but I'll contact you later today.

-Matt
Logged
Pages: [1] 2 3 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!