Author Topic: Tagging images corrupts icc profile  (Read 7340 times)

G-Force

  • Guest
Tagging images corrupts icc profile
« on: October 30, 2006, 06:25:59 PM »
I was just going through a folder of NEF files and tagging some of the images that I wanted to throw away when I noticed something: Everytime I tagged an image, the ICC profile went from "Nikon Adobe RGB" to "undefined" in the info section. When I open the image with an undefined profile in Nikon Capture it doesn't detect the image as having a color profile when I go to do a Save As. I don't know what's causing this since I've tagged images before and nothing happened to the icc profile. I can't reproduce this reliably but I have noticed "undefined" icc profiles before. I just couldn't track down what was causing it until now. I can supply a NEF with an undefined profile if that would help.

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
    • Camera Bits, Inc.
Re: Tagging images corrupts icc profile
« Reply #1 on: October 31, 2006, 10:26:36 AM »
Can you tell me whether or not you are using the latest 4.4.3.3 version of Photo Mechanic and what OS and camera you have?

I can't reproduce this myself.

I'll contact you privately for an upload address...

--dennis

G-Force

  • Guest
Re: Tagging images corrupts icc profile
« Reply #2 on: October 31, 2006, 11:20:51 AM »
Yes, I am using the latest 4.4.3.3 version of PM. I can't reproduce it consistently. For example, last night I was tagging the keepers in a folder of about 100 images that had already been processed with Nikon Capture 4.4.2. The first few images that I tagged were fine, then all of a sudden the images that I tagged started losing their icc profiles.

I'm using OS X 10.4.8 and a Nikon D2X camera. I'll send you some NEFs when I get home from work.

Offline dennis

  • President
  • Camera Bits Staff
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
    • Camera Bits, Inc.
Re: Tagging images corrupts icc profile
« Reply #3 on: December 14, 2006, 04:13:03 PM »
Hey G-Force,

OK, I finally figured-out what is happening here.  Please bear with me since this is a long and detailed reply.

These files were saved from Nikon Capture 4.4.2 (as you mentioned), and unfortunately Nikon Capture doesn't properly format their IPTC data when they write the new NEF file (maybe they do in some circumstances but not in the "before" sample photo you sent me).  This could also be true for TIFF files saved by Capture.  Photo Mechanic relies-upon files being properly formatted (as most software does) and therefore when they aren't, strange things can happen.  What is happening in this case is that Nikon claims the size of the IPTC data is 103 x 4 bytes = 412 bytes long (the x4 is because IPTC data is officially an array of 4 byte "longs").  In actuality, Nikon only wrote 410 bytes for the IPTC data - they should have inserted 2 more bytes in the file as pad to make the IPTC record a multiple of 4 bytes.  Normally this won't be an issue because the loading of this "truncated" IPTC record is easily dealt with.

The problem occurs when you update the IPTC.  Photo Mechanic by default "masks" old IPTC data when it has to relocate the IPTC block due to the increase in size.  You are probably saying "I only tagged the file!", but if you have the Preferences/Files tab setting for "Save/Load tag and color class in IPTC/XMP" to something other than "Never", then tagging a photo causes the IPTC to be updated.  Since this increases the size of the IPTC block, it has to be relocated.  The old IPTC data is then masked (so it isn't in clear text - typically one doesn't want old edits to be visible).  But since the claimed size of the IPTC is 2 bytes more than the size it actually occupies in the file, PM will mask the first two bytes of whatever follows the IPTC block.  This happens to be the ICC profile, causing it to now have an invalid size.  When PM loads the ICC profile, it doesn't like seeing a bogus size (a large negative number in this case) and so it ignores the embedded profile.

A workaround "fix" for this in Photo Mechanic is both ugly and specific to this bug in Nikon Capture (i.e. it involves us checking for specific types of bad formatting).  I'll put this in for 4.5, but Nikon should be made aware of this problem and if we are lucky there will be a 4.4.3 fix to Nikon Capture.

In the meantime, you will probably want to undo the IPTC change (Tools menu, revert TIFF-based RAW).  This will get you back to the file written by Capture (probably minus the tag).  Then change the preference mentioned above to Never.  Unfortunately, this isn't ideal since any further actual IPTC changes to the NEF with PM will cause the same problem to occur (until 4.5).  The other option is to not caption in Capture so it doesn't write an IPTC record (or be lucky enough that any IPTC data causes the data to be a multiple of 4 bytes).

BTW, technically a RAW file doesn't have a profile until it is rendered (think of it as a hint).  But Photo Mechanic uses the profile to color correct the embedded JPEG, and that is why you see the difference.  If you reload this file into Capture, it still shows as Adobe RGB.

Hope this helps and isn't too much information.

--dennis
« Last Edit: December 14, 2006, 05:06:00 PM by Kirk Baker »