Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?

Started by spark, June 29, 2012, 11:09:04 AM

Previous topic - Next topic

Phil Harvey

Looking in more detail (with the -v3 option), I found a difference that might possibly cause problems for your Nikon viewer:

I wrote CFARepeatPatternDim as int8u, but Nikon writes this as int16u.  You can change this in your copy of lib/Image/ExifTool/Exif.pm to check to see if this is a problem. (search for "CFARepeatPatternDim", then change the Writable attribute from 'int8u' to 'int16u')

- 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 ($).

Phil Harvey

I just installed LR4 on this machine so I could try it before I went home:

LR 4.1 (on OS X Lion) had no problems opening any of the NEF's you sent after they were fixed (even with the int8u CFARepeatPatternDim).  It couldn't open any of the corrupted images before they were fixed.

- 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 ($).

spark

Ok, will check out the int8u/int16u possibility but let's see how the LR4 and DcRaw will go. You used the latter with Gimp or standalone?

spark

Spot on Phil you Wizard of EXIF, King of Metadata Hill,... !!!
Changing CFARepeatPatternDim to int16u, sure did the trick! The NEFs work fine again, using Nikon Software!

Would you have a look at some compressed NEFs too for me, in case that the fix doesn't work with those?

Phil Harvey

Sure.  Send me a pair of compressed NEF's, a good one, and the same image corrupted by Nikon Capture 1.  The compressed images won't be fixed by the ExifTool version I posted.

- 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 ($).

spark

Cheers :D
Sent you an email with the link to them files.

-Sascha

Phil Harvey

#21
Hi Sascha,

I got the files, thanks.

I can also recover the corrupted compressed images.

It was a bit tricky adding the logic to set the required tags differently for the two different types of files (Compression, StripByteCounts, StripOffsets, RowsPerStrip and BitsPerSample are different).

I have updated the modified version of ExifTool to add support for compressed images.  The "fix_corrupted_nef.args" file has also been updated in this version.

This modified version should only be used on corrupted NEF's, and will only work for NEF's from the D800, but it should fix both compressed and uncompressed NEF's.

- Phil

Update: This procedure has been improved.  Click here for complete details.
...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 ($).

spark

Hi Phil,

I just tried the new version but somehow it won't work for me, even after changing int8u into int16u in "exif.pl" and modifying the "fix_corrupted_nef.args" to my best knowledge...

You're talking about a logic to set required tags differently. Where can this logic be found?
The updated "fix_corrupted_nef.args" doesn't seem to reflect this logic and seems to be aimed at 14bit uncompressed D800 NEF.

Could you let me know, which tags I need to add/modify, when fixing 12 bit, losless compressed D800 NEFs and what the modifications are? I'd create a seperate .args file on this basis.

Thanks in advance,

- Sascha

Phil Harvey

Hi Sascha,

I think you may be using the wrong version.  The new version should already be writing CFARepeatPatternDim as int16u (use the -v3 option to see this).  This is now defined in lib/Image/ExifTool/WriteExif.pl, which is where all of the "fixing" logic is (search for the string "TEST").

You are correct that the fix_corrupted_nef.args doesn't reflect the logic to set the tags differently for the compressed image.  This is done in the code.

- 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 ($).

spark

Hi Phil,

I sure was using the wrong version, thanks to our proxy...
Everything works fine and flawless now :D

Thanks again for helping out!

If you're interested in creating a fix for the other RAW variants, I can provide you with the samples needed.

-Sascha

Phil Harvey

bringing the email conversation back to the forum...

Quote from: spark on July 05, 2012, 10:20:06 AM
The samples I sent you were both 12 Bit, lossless compressed and my test were based on the Nkt1lc.nef.

On D800 you can choose between 12 Bit and 14 Bit, with variants uncompressed, lossless compressed and compressed Raw (smaller but lossy).

Hi Sascha,

It seems we have more work to do then, to support the 6 possible variants.

I can recognize the uncompressed types by the size of the data, but distinguishing between the compressed versions may be more difficult.

If you could provide corrupted and uncorrupted samples of all the NEF variants (I already have samples for two), then I will try to build a general version to support any format of corrupted D800 NEF.

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 ($).

Phil Harvey

Hmmm.  There could be 12 variants...

I some googling and it seems the NEF files are different for the DX and 1.2x crop modes.

This is going to be a bit of work. :(

- 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 ($).

spark

You're right! Haven't even thought about that!
So in theory that would be 18 different combinations!

But I'd say, let's keep it simple, since nobody usually uses the cropped modes... unless you really want to have a look into this ^^

I will upload them samples later and will drop you an email fyi.
It will be 6 corrupted and 6 fine NEFs, file names will explain which is which.

- Sascha

spark

Hi again Phil,

Upload is finished, email is sent.

Cheers and good luck figuring this one out!

Phil Harvey

Thanks.  I'll let you know how it goes. :)

I'm pushing hard to get this done ASAP because I leave on Saturday for a 2-week vacation.

- 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 ($).