Writing Prefs tag sets incorrect PhotoMechanic:Tagged value

Started by Hayo Baan, June 25, 2014, 05:02:12 AM

Previous topic - Next topic

Hayo Baan

Hi Phil,

Been doing some heavy metadata checks/corrections on my files (again, yeah, still busy...) and found a bug when updating the photomechanic Prefs in a file.

First of all, exiftool also updates the Tagged tag underwater, though I did not ask it to (it doesn't do this for the ColorClass or Rating either by the way), but worse, it fills it with the incorrect value (i.e., the whole of the raw prefs value instead of just the value of Tagged). Here's some test output:
$ exiftool -wm w -Prefs="Tagged:0, ColorClass:2, Rating:1, FrameNum:123456" T.nef
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - T.nef
    1 image files updated
$ exiftool -G0:1 -a -ColorClass -Rating -Tagged -Prefs T.nef
[PhotoMechanic] Color Class                     : 0 (None)
[XMP:XMP-xmp]   Rating                          : 1
[PhotoMechanic] Rating                          : 0
[PhotoMechanic] Tagged                          : Unknown (0:2:1:123456)
[XMP:XMP-photomech] Prefs                       : Tagged:0, ColorClass:2, Rating:1, FrameNum:123456
[IPTC]          Prefs                           : Tagged:0, ColorClass:2, Rating:1, FrameNum:123456

$ exiftool -wm w -Prefs="Tagged:1, ColorClass:4, Rating:3, FrameNum:123456" T.nef
    1 image files updated
$ exiftool -G0:1 -a -ColorClass -Rating -Tagged -Prefs T.nef
[PhotoMechanic] Color Class                     : 0 (None)
[XMP:XMP-xmp]   Rating                          : 1
[PhotoMechanic] Rating                          : 0
[PhotoMechanic] Tagged                          : Unknown (1:4:3:123456)
[XMP:XMP-photomech] Prefs                       : Tagged:1, ColorClass:4, Rating:3, FrameNum:123456
[IPTC]          Prefs                           : Tagged:1, ColorClass:4, Rating:3, FrameNum:123456
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I don't understand what is going on.  Could you email me the sample image (philharvey66 at gmail.com)?  Thanks.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

Hi Phil,

Yeah, really bizarre. I just sent you the sample NEF file I used for testing.

Note that it almost certainly has to do with the fact that it is a [PhotoMechanic] group tag; updating the [XMP:XMP-photomech] goes well.
In my testing, I also found that I can't create the PhotoMechanic:Tagged tag, but perhaps that is Expected? Note that updating the tag PhotoMechanic:Tagged goes fine.

$ exiftool -a -G0:1 -Tagged# -Rating -ColorClass -Prefs T.nef
[PhotoMechanic] Tagged                          : 0:2:5:623451
[XMP:XMP-xmp]   Rating                          : 1
[PhotoMechanic] Rating                          : 0
[PhotoMechanic] Color Class                     : 0 (None)
[XMP:XMP-photomech] Prefs                       : Tagged:0, ColorClass:2, Rating:5, FrameNum:623451
[IPTC]          Prefs                           : Tagged:0, ColorClass:2, Rating:5, FrameNum:623451
$ exiftool -a -G0:1 -wm wcg -PhotoMechanic:Tagged=Yes T.nef
    1 image files updated
$ exiftool -a -G0:1 -Tagged# -Rating -ColorClass -Prefs T.nef
[PhotoMechanic] Tagged                          : 1
[XMP:XMP-xmp]   Rating                          : 1
[PhotoMechanic] Rating                          : 0
[PhotoMechanic] Color Class                     : 0 (None)
[XMP:XMP-photomech] Prefs                       : Tagged:0, ColorClass:2, Rating:5, FrameNum:623451
[IPTC]          Prefs                           : Tagged:0, ColorClass:2, Rating:5, FrameNum:623451


Hope you can find the cause (and a solution). Looking at your code, I can't figure it out (but then I don't yet fully know how the innards of exiftool work, of course).
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

NICE CATCH!

I am really enjoying your attention to detail and your impressive logic skills.

This is an ExifTool bug that has existed since version 8.35.  It occurs because ExifTool is incorrectly writing standard IPTC tags into the proprietary PhotoMechanic SoftEdit record (which is also IPTC format).  The bug is due to a slip where I used "=" instead of "eq" in a logic statement.

This will be fixed in ExifTool 9.66.

Thank you very much for pointing this out!  You should win some sort of a prize for this one.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

Hello Phil,


Quote from: Phil Harvey on June 25, 2014, 09:13:44 AM
NICE CATCH!

I am really enjoying your attention to detail and your impressive logic skills.

Thanks, you're welcome :D

Though I am now a full time photographer/workshop leader, in my previous career I worked in IT (first as developer and finally as project manager). I still write programs (Perl scripts mostly) and make heavy use of Exiftool. My current project is a toolset to check the metadata of my images. One of the things it does is see if all tag "synonyms" and duplicates have the same value and correct them if not. As a test case I ran it on on my old images and this is where I ran into the issue.

Quote from: Phil Harvey on June 25, 2014, 09:13:44 AM
This is an ExifTool bug that has existed since version 8.35.  It occurs because ExifTool is incorrectly writing standard IPTC tags into the proprietary PhotoMechanic SoftEdit record (which is also IPTC format).  The bug is due to a slip where I used "=" instead of "eq" in a logic statement.

Ah, the dreaded "=" or "==" or "eq". Most of the times Perl warns you about these errors, but they can still sometimes rear their ugly head ::)

Quote from: Phil Harvey on June 25, 2014, 09:13:44 AM
This will be fixed in ExifTool 9.66.

Thank you very much for pointing this out!  You should win some sort of a prize for this one.

Excellent, 9.66 is going to be much anticipated by me now  ;D
And the prize for this one I already have: great software and fun poking around with it ;)

Thanks,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl