ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: spark on June 29, 2012, 11:09:04 AM

Title: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on June 29, 2012, 11:09:04 AM
Hi Phil,

I have stumbled upon a problem in which D800 NEFs SubIFD Tags got corrupted, when transfered with older Nikon-Software (Nikon Transfer 1).

Do you see any possibility to rewrite these tags and replace the ones missing, for instance on the basis of a not corrupted NEF?

For comparission I've attached the Metadata in TXT-form, of the same image, in both it's corrupted and uncorrupted form. nkt1.txt represents the corrupted NEF, nkt2 the one that isn't.

Thanks a lot for looking into this and a good weekend to you!
-Sascha

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 29, 2012, 06:39:38 PM
Hi Sascha,

Wow, it really made a mess of the RAW image IFD. :(

It may be possible to recover the data, but I can't tell from this output.  It would be tricky though, because you would have to somehow re-generate the list of strip offsets/sizes, but since the raw image is uncompressed, I think this may be possible.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on June 30, 2012, 02:52:55 PM
Hi Phil,
NkTransfer sure did a great job messing up the IFD didn't it ^^

Ufff... yeah, noticed the missing strip offset/sizes :P
My friend who did this mess is helpless... absence minded as he was, he transfered the NEFs with the first best application that came up... in his case Nikon Transfer 1, which ain't supposed to be used with D800. It was only days later that he noticed the mess. Having used the memory card the NEFs were stored on extensively since, there is no chance of retrieving the originals again :P The pictures of course were for a big costumer... so he prety much has putten his relations with them at risk.

I'd really like to help him out but haven't managed with my limited knowledge yet. If there's any direction and/or good resources for self-study you could point us at, we'd really appreciate it!
I wouldn't want to ask you for any more of your time but any help is welcome.

Best regards,
Sascha

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 01, 2012, 02:50:14 PM
Hi Sascha,

Quote from: spark on June 30, 2012, 02:52:55 PM
Hi Phil,
NkTransfer sure did a great job messing up the IFD didn't it ^^

Certainly a big embarrassment for their software department, that's for sure!  Software like this really should be forward compatible, and should abort with a warning instead of corrupting the file if it sees anything it doesn't recognize.

If you send me one of the corrupted files I'll take a look at it (philharvey66 at gmail.com).  Your only other chance is if someone has already run into the problem and come up with a solution.  But if Google doesn't turn up anything, your only chance may be some custom programming if it is possible at all to recover the file.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 01, 2012, 06:24:19 PM
I can only agree come to Nikon Software... Despite the many steps forward they have made, these things clearly shouldn't happen...

As to others having run into the same problem and having found a solution... so far I haven't stumbled upon these people, which is why I turn to you Phil aka my Metadata / RAW filestructure god ^^

I can't find the words to express, how your and the colaborative effort of other exif tool followers/users, has helped me in the past. Donation is on it's way!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 01, 2012, 06:27:21 PM
and done... 44L9667....

I <3 EXIF TOOL  :)
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 02, 2012, 07:36:35 AM
Hi Sascha,

I got the images, and the donation, thanks!

I'll take a look at the images (probably tomorrow), and let you know what I find.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 03, 2012, 08:30:07 AM
I failed in my first attempt to recover the image:  I rebuilt the entries in SubIFD1 by adding the missing tags and using the "OtherImage" as the raw strip data.  Unfortunately, this did not produce a readable image.

I notice that the OtherImageLength is exactly 73111552 bytes in all of the samples you sent.  However, in good D800 NEF images the StripByteCounts varies and is about 3 or 4 MB.  This isn't a good sign, but there is a small chance that the original strip data still exists somewhere in the OtherImage data.  I can test for this if you can provide me with 2 more samples:

1) A good original NEF from the D800.

2) The same NEF as corrupted by Nikon Transfer 1.

You would of course need to shoot a new image, then download it using the 2 different techniques (by copying directly, and by using Nikon Transfer 1).

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 03, 2012, 08:49:34 AM
Good man yourself.
Actually have exactly the files you need.

Will upload them and send you a link via email!

Thanks again for your efforts!

;)-Sascha
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 03, 2012, 10:21:20 AM
Having troubles with the upload... will send you the email later this day...
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 04, 2012, 07:49:58 AM
Hi Sascha,

I got the images, thanks.

I think I can recover the original raw image, but it will take some work.  The corrupted file does contain the original raw data.  Give me a bit more time to work on this.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 04, 2012, 08:00:29 AM
Hi Phil,

I'm happy enough that somebody seems to be able to help me out on that matter, so thanks again and please take your time :D

In case you're able to recover the images, I'd be happy if you could let me know how.
The more detail, the better but any info would do.

Cheers and best regards,
Sascha

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 04, 2012, 09:26:25 AM
I did it!

I have a created a patched version of ExifTool that is able to fix all of the corrupted NEF images you sent.

It currently works on uncompressed NEF images only.  I would need samples of compressed NEF images to be able to fix these too.

The command looks like this:

exiftool -@ fix_corrupted_nef.args SRCDIR -o OUTDIR

With this command, exiftool will repair all of the corrupted uncompressed NEF images in directory SRCDIR and write the fixed images to directory OUTDIR.

Here is the patched version of ExifTool (https://exiftool.org/Image-ExifTool-8.97_fix_corrupted_nef.tar.gz) (including the "fix_corrupted_nef.args" argument file).  You must have Perl installed to run this.  (you already have this installed unless you are running Windows)

The patched version effectively regenerates the necessary StripOffsets and StripByteCounts in SubIFD1 of the NEF, and the .args file writes the other tags required in SubIFD1.

Let me know if you have any questions or problems.

- Phil

Update: This procedure has been improved.  Click here for complete details (https://exiftool.org/fix_corrupted_nef.html).
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 04, 2012, 11:21:40 AM
Hi Phil,

Tried your suggested fix but the NEFs created this way, still can't be opened (at least not in Capture NX 2).
Will try if they'll open in CS5 and will let you know what happens.

You said it worked for you? Have you confirmed that the NEFs can be opened again and if yes, in which software?
If everything works fine for you, I'd be happy if you could upload them 6 D800 NEFs (Netto_xxx.nef) somewhere, where I could download them.


Checking the changes in Metadate between original and "fixed" NEFs I've noticed, that compared to the last samples I sent you (Nkt1.nef and NKT2.nef), there were a few differences still in SubIFD, SubIFD1, SubIFD2 and PreviewIFD.
I edited the "fix_corrupted_nef.args" to include those changes, which worked in all cases except for PreviewIFD, which I don't think is so relevant anyway, unfortunately to no avail...

Come to the StripOffsets in SubIFD1 I noticed a difference of 1 byte too (according to Exif Tool) but didn't get to check it further.

Thanks for everything you did so far, especially the bit about regenerating the StripOffsets and StripBytecounts!

I'll probably get back to you on the matter of compressed NEFs...

-Sascha
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 04, 2012, 12:06:59 PM
Hi Sascha,

Yes, it worked for me using Apple Preview on Mac OS X Lion to open the fixed NEF image.  Just to be sure, the fixed NEF should look like this:

> exiftool -a -subifd1:all fixed.nef
Subfile Type                    : Full-resolution Image
Image Width                     : 7424
Image Height                    : 4924
Bits Per Sample                 : 14
Compression                     : Uncompressed
Photometric Interpretation      : Color Filter Array
Strip Offsets                   : (Binary data 10949 bytes, use -b option to extract)
Samples Per Pixel               : 1
Rows Per Strip                  : 4924
Strip Byte Counts               : (Binary data 7385 bytes, use -b option to extract)
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
CFA Repeat Pattern Dim          : 2 2
CFA Pattern 2                   : 0 1 1 2
Sensing Method                  : One-chip color area


The StripOffsets size may be different, but everything else should be identical for all images.

I don't have any other software I can test with here, but I have LR4 at home that I can check.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 04, 2012, 12:32:57 PM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 04, 2012, 12:59:29 PM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 04, 2012, 02:35:30 PM
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?
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 06:14:56 AM
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?
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 07:19:12 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 07:26:05 AM
Cheers :D
Sent you an email with the link to them files.

-Sascha
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 09:06:00 AM
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 (https://exiftool.org/Image-ExifTool-8.97_fix_corrupted_nef.tar.gz) 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 (https://exiftool.org/fix_corrupted_nef.html).
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 09:42:45 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 09:46:20 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 10:20:06 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 10:27:20 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 10:33:25 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 11:11:09 AM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 01:48:24 PM
Hi again Phil,

Upload is finished, email is sent.

Cheers and good luck figuring this one out!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 05, 2012, 02:33:51 PM
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
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 05, 2012, 03:49:57 PM
Thanks Phil, much appreciated!
You'll deserve them holidays even more. You heading abroad?

If you can't make it, no problem. You've already done so much!

In case I don't read you before, enjoy them holidays!

-Sascha
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on July 06, 2012, 08:09:13 AM
Hi Sascha,

I can identify the compression from the NEFCompression tag in the maker notes, but I'm not currently decoding the bit depth from the maker notes (NEFBitDepth is not available for some reason, and the BitsPerSample from SubIFD1 is deleted by Nikon Transfer 1).  So it will take some work to figure out how to identify the bit depth in order to produce a general fix.  I'll work on this, but it isn't likely I'll be able to figure this out before my vacation.  I'm going to Iceland with my wife and son.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on July 06, 2012, 08:14:40 AM
I see... sure sounds difficult, especially given the mess Nikon Transfer did!
I'm curious to see, whether or not you'll be able to figure this one out ^^

But please don't make it a priority, and above all, a lovely holiday to you and your family :D
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: MC Photo on August 12, 2012, 01:52:14 PM
Hello Phil & spark,

I'm new to ExifTool but I too like spark have fallen into the Nikon Transfer 1 trap with the D800. Since I have the RAWs that are unreadable and the memory cards are unrecoverable, I'm stuck. It seems as though you're the only one on the internet to have made progress on this front. Like I said, I'm very new to ExifTool and using Mac's terminal, but I would love to know what steps I need to take to recover these photos. These are valuable photos of a personal nature and would very much appreciate your help. Thanks Phil!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 13, 2012, 06:49:28 AM
The modified version of ExifTool that I posted may be able to fix your corrupted D800 NEF's, depending on the compression settings you used.  To run this version you need Perl installed. See the ExifTool installation instructions (https://exiftool.org/install.html) for the full Perl distribution.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: MC Photo on August 14, 2012, 04:54:01 PM
Thanks Phil, I have everything installed and set up according to your previous posts, but being very much an infant when it comes to Terminal and ExifTool, I haven't been able to figure it out and keep getting error messages. I'm sure it's simple and I'm embarrassed to ask, but would you mind giving me specific step by step instructions in layman's terms on what I need to do? Thank you so much in advance
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: MC Photo on August 14, 2012, 04:58:44 PM
And for your time Phil, I'll be more than happy to send a donation your way. Your help is very appreciated.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 14, 2012, 06:53:40 PM
The technique is:

1) download and install ActivePerl (http://www.activestate.com/activeperl/).

2) download and expand the patched version of exiftool (https://exiftool.org/Image-ExifTool-8.97_fix_corrupted_nef.tar.gz).

3) From the Windows Start menu, run "cmd.exe"

4) In the cmd.exe window, change directories to the ExifTool distribution folder by typing "cd" pressing SPACE, then dragging and dropping the expanded exiftool folder onto the cmd.exe window, and finally pressing RETURN.  (You should now be able to type the "pwd" command to see the current directory name.)

5) In the cmd.exe window, type "perl exiftool -@ fix_corrupted_nef.args -o fixed" (without the quotes), then press SPACE, then drag and drop the folder containing the NEF images to be fixed, and press RETURN.

6) exiftool will run, perhaps giving some warning messages.  If things go well, exiftool will create a new folder called "fixed" inside the ExifTool distribution folder.    (And the "dir fixed" command should now give you a list of the NEF files in the "fixed" folder.)  This new folder will contain the fixed NEF images with the same file names.  With any luck, you will now be able to open these new NEF files.

Good luck.


- Phil

2012-09-08 Update: I have created a new "fix_corrupted_nef" utility that fixes any FX-format D800 or D800E NEF.  Versions are available for Windows and Mac/Linux:

Click here for instructions on how to download and run the "fix_corrupted_nef" utility (https://exiftool.org/fix_corrupted_nef.html)
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Arthur on August 30, 2012, 05:05:06 PM
Hello Phil,
It seems that you can save my life...
I have the same problem with my new D800... I just bought it before leaving for the french Polynesia ( I saved money during 15 years for that) and transferred all my pictures to a hard disk with Nikon Transfer... When I came back, I have seen that the files were corrupted!  :'(
I then tried your technique without success !
I just receive the following message :

"Can't locate Image/ExifTool.pm in @INC (@INC contains: ./lib C:/Perl64/site/lib
C:/Perl64/lib .) at exiftool line 30.
BEGIN failed--compilation aborted at exiftool line 30."

The pictures I took are 14 bit, not compressed. Is it the reason ? You may have an idea ?

I tried with the PC of my son. But it seems I could use my MacBook?

With my MAC, I tried the patched version for uncompressed file, created the files SRCDIR and OUTDIR in the ExifTool-8.97_fix_corrupted_nef folder (in the application folder) placed the corrupted nef file in the SCRDIR file and tried the commend but received the message :

MacBook-Pro-de-Jacques-Blanc:~ jblanc$ exiftool -@ fix_corrupted_nef.args SRCDIR -o OUTDIR ; exit;
-bash: exiftool: command not found
logout

It seems that there are a lot of things I do not understand... Sorry

If you could help me, I would be more than happy to make a donation (if you tell me how) !!!

Thank you very much.

Arthur

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 30, 2012, 07:57:55 PM
Hi Arthur,

The "lib" directory must exist in the same directory as "exiftool".  If you moved exiftool somewhere, also move the lib directory to the same location.  If exiftool isn't in your path, then type the full path name instead of just "exiftool" (or just drag and drop it onto the Terminal window and OS X will type the full path name for you).  Your Mac already has Perl installed, so you can do it on the Mac without needing to install Perl.

Also, drag and drop the "fix_corrupted_nef.args" file into the Terminal window instead of typing "fix_corrupted_nef.args" so you get the proper path for this file too.  One last thing: You need to replace SRCDIR and OUTDIR with the actual directory name of your images and the directory where you want the fixed images to be stored.  Again, you can drag and drop these folders onto the Terminal window to save typing.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Arthur on August 31, 2012, 05:11:00 PM
Hello Phil,

I asked the son of a friend, student in computer science, to help me. I gave him all your indications and it seems that he is going to succeed...
I will let you know. Anyway, thank you so much for your help. As I told you, I am ready to give you a donation for your time and for your knowhow... I just need to know how to do it. Could you send me an e-mail?

Arthur

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 31, 2012, 07:58:52 PM
Hi Arthur,

I hope it works, but since you are using uncompressed NEF's I think it should.

No donation is necessary, but if you really insist there is a Donate button on the ExifTool home page (https://exiftool.org/index.html#donate).

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: ph0enixx on September 04, 2012, 11:16:41 AM
Hello Phil,

First of all, Thank You for the great job You've done.

I've got in similiar situation with Nikon transfer 1.5.3, my NEFs was D800 14 bit compressed. I've tried Your solution, and it partially helped, excludes bits of depth because Capture NX crashed while opening that NEFs.
So I found the way how You figuring out what type of depth in the file
    $newVal = ($nefSize == 73111552 ? 14 : 12); in WriteExif.pl
and I changed it to     
    $newVal = 14 ;
May be this not good solution but NEF opened.

- Robert
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 04, 2012, 12:51:06 PM
Hi Robert,

Great.  This solution is fine if you always use the 14-bit NEF files.  I don't recall if there were any other tags which may need changing for the compressed image, but if it opens then they can't matter too much anyway.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 06, 2012, 01:47:07 PM
I just got a sample corrupted 14-bit compressed NEF and tried this myself.  Worked fine.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: SRC on September 07, 2012, 01:25:54 PM
Hi,
I just downloaded and used the method mentioned above to save many corrupted d800 NEF files (used nikon transfer 1) I didn't know how to fix for 2 months. 
This process works like a charm, and the step by step is a big help for people like me who can't handle computers very well. This is the one and only way to fix to this problem many people have been experienced when first using d800.
Brilliant. Thanks a lot Phil!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Arthur on September 08, 2012, 12:25:42 AM
Hello Phil
Many Many thanks. I got back all my pictures. I didn't expect so much. It's realy fantastic.
I am travelling in Canada for business, but as I promised, I will make a donation when I'll be back home.
Thanks again.
Arthur
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 08, 2012, 09:36:55 AM
Great!  Glad to hear it is working well.

I've just created an EXE version of this utility for Windows.

Click here for full details (https://exiftool.org/fix_corrupted_nef.html)

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: bobfrost on September 11, 2012, 04:46:46 PM
Hi Phil,

It's great that you've worked out how to do this. Could you update it to work with the normal FX files; I know someone who has corrupted loads of D800 nefs and deleted the originals on his cards!!

Bob Frost
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 11, 2012, 07:16:24 PM
Hi Bob,

Ooops, sorry.  Somehow "DX" got stuck in my head, and I was thinking that this was the normal format.   All my test files are 7424x4924 pixels, which (after some googling) looks to be FX.  I got my terminology wrong. 

I'll update the documentation.

- Phil

Edit: The web page (https://exiftool.org/fix_corrupted_nef.html) and a previous post in this thread have now been updated.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: renato on September 12, 2012, 11:06:16 AM
I believe you are saving lives here!! But I just found another issue using Nikon View NX (new version).

Nikon Transfer old version corrupts a D800 file when transferring the files but the file size doesn't change. This way your miracle tool CAN heal the file. But if the corrupted file (not healed yet) has a label or rating applied to it using the Nikon View NX (new version) instantly the file turns to 72 dpi and has its size drastically reduced (like 74mb original turns immediately to 2 Mb). After that it cannot be healed anymore and it opens with Photoshop normally in a very small size.
I lost 140 files I labeled this way.

Comparing the Corrupted file (not healed with Exif tool) these are the aspects that changed:
BEFORE LABEL >>> AFTER LABEL :

File Size: 74 MB >> File Size: 4.2 MB
Software: Nikon Transfer 2.1 W >>> Software: ViewNX 2.5 W
Jpg From Raw Start: 184981 >>> Jpg From Raw Start: 185735 (lenght didn't change)
X Resolution: 1.525855624e-005 >>> X Resolution: 72 (after correction the labeled and the non labeled became 300, but the labeled did not open anymore)
>>>In the labeled file it appeared: Rating Percent: 0 (there was no rating percent in the non labeled)
Preview Image Start: 84422 >>>Preview Image Start : 84422
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 12, 2012, 12:04:18 PM
Wow, this sucks. :(

I call this a bug.  If you use ExifTool (any version) to write the corrupted files, the raw data is preserved and the file can still be repaired afterward.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: renato on September 12, 2012, 12:16:42 PM
The Nikon Transfer problem can be corrected with EXIF tool.  But this drastic size reduction when labeling with  Nikon View I believe is irreversible.
I tried to fix these reduced files with EXIF but although the resolution changed the file size did not recover. And they don't open after the correction.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 12, 2012, 12:23:44 PM
Yes, I agree.  There is no way that the NikonView double-corrupted files are repairable because the original raw data is certainly lost.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on September 26, 2012, 10:29:03 AM
I have just uploaded a new version of this utility that supports the D4 as well as the D800/D800E.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: davidgoerndt on December 27, 2012, 03:15:51 PM
New here, I just downloaded the exe to fix corrupted NEF files. When I open the exe, I get a prompt to hit any key and the prompt goes away with nothing happening.
David Goerndt
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: davidgoerndt on December 27, 2012, 03:35:04 PM
Disregard the previous post. I managed to figure out what i was doing wrong. The files that were corrupted are now fixed and back to their original image size. Thanks for this beautiful little app!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: banjoinn on January 02, 2013, 09:47:42 PM
I've been struggling with this problem over the last few days. I'm wondering if there is anything more on reply #49. I've found that your program works great for files corrupted by ViewNX from a D800 that were taken in FX format. However, it doesn't work for files taken on the same camera in DX format. (I'm using Windows 7 Home premium).
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 03, 2013, 07:13:29 AM
I should be able to add support for DX-format images, but I will need a set of 12 test images comprised of the following 6 images a) copied directly from the camera's memory card, and b) downloaded via Nikon transfer 1:

1) 12-bit compressed
2) 12-bit lossless compressed
3) 12-bit uncompressed
4) 14-bit compressed
5) 14-bit lossless compressed
6) 14-bit uncompressed

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: banjoinn on January 03, 2013, 10:22:57 PM
That would be great, and I am sure there are others that would benefit. I've prepared the files - but there are 532 MB of them, so what is the best way for you to get them?
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: banjoinn on January 03, 2013, 11:27:54 PM
Correction - 520 Mb when in FX format, 232 Mb in DX format. I can put them on an ftp site if that's the easiest way to transfer them.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 04, 2013, 07:06:20 AM
Whatever is best for you.  My mail can easily take files of this size (one per email).

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 04, 2013, 08:26:03 PM
Thanks, I got the files.  If all goes well, my hope is to have a new version of fix_corrupted_nef that will handle D800 DX images ready for Monday.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 07, 2013, 07:35:21 AM
I have just released a new version of the fix_corrupted_nef utility (https://exiftool.org/fix_corrupted_nef.html) that will fix these D800 DX images.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Cloudbuster5 on January 13, 2013, 03:38:33 PM
I have this problem with the pictures I took while on a trip. I sent you a link to the photos. Anything you can do will be appreciated. The camera is a D3200. Thanks,
Van
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 13, 2013, 06:01:34 PM
Darn.  Are you telling me this problem (downloading with Nikon transfer 1) affects D3200 NEF's too?  :(

If so, I will need a full set of sample NEF's to add support for this model (see this post (https://exiftool.org/forum/index.php/topic,4220.msg22342.html#msg22342) for the required samples).

I can't take a look at the images until tomorrow, but if this is the problem then you can speed things along by sending me these samples (you can mail them to philharvey66 at gmail.com).

- Phil

Edit:  I've taken a look at your image, and it does look like a typical Nikon-Transfer-1-corrupted NEF.  I can add support for the D3200 if you send me the full set of test images that I mentioned.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Cloudbuster5 on January 14, 2013, 08:58:13 AM
The camera only shoots one kind of raw. From the spec: Compressed 12-bit NEF (RAW)
JPEG: JPEG-Baseline Compliant with fine (approx 1:4), Normal (approx 1:8) or Basic (approx 1:16) Compression
NEF (RAW) + JPEG: Single Photograph Recorded in both NEF (RAW) and JPEG Formats

I updated the view nx and tranfer when I got home, so I can't make anymore corrupt files. I can send raw files from the newest transfer program.

Thanks, Van
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 14, 2013, 11:24:08 AM
Hi Van,

OK, thanks.  So the sample you already sent covers the full set of NEF file types. :)

I'll get working on adding support for the D3200 then, and I'll post back here when I have something (probably a day or two).

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 15, 2013, 07:26:23 AM
There you go.  I have uploaded fix_corrupted_nef (https://exiftool.org/fix_corrupted_nef.html) version 1.4 that adds support for the D3200.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: j_p on February 25, 2013, 04:39:11 AM

Hi Phil,

I´ve got a Problem with the RAW files of the D800E. I´ve downloaded the RAW files directly from the CF Card and opened it with an old version of CaptureNX 2, it´s V2.0.0, to edit the RAW files.
CaptureNX 2 overrided the original RAW file. Now I have an RAW file with the dimensions 1632 x 1080 pixel. I can open it in any RAW converter but only with this dimensions. After i processed it with the fix_corrupted_nef.pl I can display the file in ViewNX 2 but I can´t convert it. I can´t open the processed file in any other RAW programm.

Thanks for your help!

Jonas
Modify message
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 25, 2013, 07:23:37 AM
Hi Jonas,

Could you send me one of the files (before you ran fix_corrupted_nef on it)?  My email is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 26, 2013, 08:08:07 AM
Hi Jonas,

I got your image.

Sorry to be the bearer of bad tidings, but the raw data in the image you sent looks to be corrupted beyond repair.

Somehow it looks like the Nikon Capture program confused the RAW data with the preview image and stored a JPEG preview over top of the raw data in this file.

I don't see anything in there that looks like good raw data any more.  Sorry.  The only thing you can do with this file is to recover the 1632x1080 JPEG preview:

exiftool -jpgfromraw -w _preview.jpg FILE

where FILE is one or more file and/or directory names.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Djovetta on May 04, 2013, 02:22:22 PM
Hi Phil, 

It's really great to see the comments on the forum, I figure my issue is a little bit more complicated but I still have hope.
My NEF files was corrupted by a brand new crap Sandisk Extreme Pro SD. After taking approximated 200 photos , the camera showed a message of error. After that, the SD does not work any more.

I used RescuePro (a Sandisk program) to download the files to my computer. But now I only can see the photos as a preview but the raw file is corrupted and I can't open it on aperture/Mac preview/viewNx 2.

I would like to know if you have ever seen this situation and if you can help me.

Thanks in advance.

Danilo
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on May 04, 2013, 09:25:03 PM
Hi Danilo,

Take a look at the image using the Exiftool -htmldump feature:

exiftool -htmldump image.nef > out.html

You take a look at the raw image data this way.  I have seen cases where it is all zeros, which is bad, and not recoverable.  Or ends with all zeros, which means that at least some of the data was lost.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: TofuCivic on May 15, 2013, 03:13:42 AM
Hi Phil,

I also have fallen into the same trap of transferring my D7100 photos with Nikon Transfer 1.  I seem to be able view the raws in ViewNX 1 and 2, but nothing else.  Have you had any requests to add support for the D7100?  I've got some photos of my newborn that I'm hoping I can still recover.  Stumbling onto this forum has given me some hope :)

Thanks in advance, your help is very much appreciated.
How
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on May 15, 2013, 07:39:54 AM
I can add support for the D7100 if you send me a full set of original and corrupted images:

12 bit uncompressed
12 bit compressed
12 bit lossless compressed
14 bit uncompressed
14 bit compressed
14 bit lossless compressed

(note: the full set is 12 images:  these 6 images copied directly from the memory card, plus the same 6 as corrupted by the Nikon software)

my email is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: TofuCivic on May 16, 2013, 01:09:30 AM
Sent.  I had issues finding an email account so I sent links to my google drive instead.  Let me know if you have issues downloading them.  To show my appreciation for your time and help, a donation is on it's way.

How
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on May 16, 2013, 07:56:35 AM
Hi How,

I got the samples, thanks.  The fix_corrupted_nef utility (https://exiftool.org/fix_corrupted_nef.html) has now been updated to support the D7100.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: TofuCivic on May 16, 2013, 10:52:02 PM
Thanks, Phil.  I gave it a try tonight and it works flawlessly. :)

Cheers,
How 
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: moomah on June 24, 2013, 06:52:59 AM
is this program for correcting corrupted .NEF's compatible with the d90?
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 24, 2013, 07:20:07 AM
Note that this utility only fixes NEF images corrupted by Nikon software.  I haven't yet seen a D90 image that has been corrupted like this.  This is an older camera that I would have thought wouldn't be affected by this bug.

So the answer is no, but I can add support for any Nikon camera if I have a set of corrupted and uncorrupted samples.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: moomah on June 24, 2013, 01:35:34 PM
how do I upload the corrupted/uncorrupted photos ?

my photos were corrupted using the nikon transfer software.

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 24, 2013, 01:46:02 PM
See this post in this thread (https://exiftool.org/forum/index.php/topic,4220.msg24236.html#msg24236) for details on how to send me samples.

What software and what version were you using?

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: moomah on June 24, 2013, 02:16:08 PM
it was Nikon ViewNX 1.5.2.

I think i only require the 12 bit images the D90 isnt capable of 14 bit.
how do i get 3 versions of the same file?
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 24, 2013, 06:33:27 PM
Just shoot as many RAW formats as supported by the D90, then copy the original images directly from the memory card and also use ViewNX 1.5.2 to download the images, then send them all to me.

- Phil

Edit:  There may be something else going on here, but I'll let you know.  I did some checking and the D90 seems to have been released in 2008, but ViewNX 1.5.2 was released 2010, so there should be no problem with this (newer software should work fine with older cameras).  If there were, then there would have been a massive outcry at the time.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: BenB on August 12, 2013, 05:27:25 PM
Hi Phil, sorry I am maybe a novice but I didn't find the way to make work your tool. I have A D600 with pb of corrupted files + a MBPro 10.8.4. Here is what I have :

Last login: Mon Aug 12 22:51:46 on ttys000
MacBook-Pro-de-Ben:~ ben$
MacBook-Pro-de-Ben:~ ben$ /Users/ben/Desktop/fix_corrupted_nef/fix_corrupted_nef.pl
---- fix_corrupted_nef version 1.9 ----
Fixes Nikon D4/D600/D800/D800E/D3200/D5200/D7100 NEF images that
have been corrupted by transferring with older Nikon software.

Syntax:  fix_corrupted_nef FILE [FILE...]

MacBook-Pro-de-Ben:~ ben$ exiftool fix_corrupted_nef
-bash: exiftool: command not found
MacBook-Pro-de-Ben:~ ben$ fix_corrupted_nef
-bash: fix_corrupted_nef: command not found
MacBook-Pro-de-Ben:~ ben$ /Users/ben/Desktop/NEF04/DSC_0001.NEF
-bash: /Users/ben/Desktop/NEF04/DSC_0001.NEF: Permission denied
MacBook-Pro-de-Ben:~ ben$ fix_corrupted_nef /Users/ben/Desktop/NEF04/DSC_0001.NEF
-bash: fix_corrupted_nef: command not found
MacBook-Pro-de-Ben:~ ben$

Can you help me ?
Thanks
Ben
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 12, 2013, 08:27:42 PM
Hi Ben,

Just download and expand the fix_corrupted_nef for Mac and follow the instructions in the included README.txt

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: BenB on August 13, 2013, 09:35:34 AM
Hi Phil,
It is what I've done -> cf. my first post -> fix_corrupted_nef is launched but why I put the NEF file, it doesn't process it.
Sure I am doing something wrong but what ?
Thanks for helping
Ben
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 13, 2013, 10:35:39 AM
Hi Ben,

If you follow the directions, before you press RETURN your command line should look something like this to fix a single NEF:

MacBook-Pro-de-Ben:~ ben$ /Users/ben/Desktop/fix_corrupted_nef/fix_corrupted_nef.pl /Users/ben/Desktop/NEF04/DSC_0001.NEF

or like this to fix all NEF's in a folder:

MacBook-Pro-de-Ben:~ ben$ /Users/ben/Desktop/fix_corrupted_nef/fix_corrupted_nef.pl /Users/ben/Desktop/NEF04

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: BenB on August 15, 2013, 03:55:39 PM
OK, Thanks, it's working perfectly !
It's sincerely nice to get back some lost nef files...It was disappointing to be reduce to jpeg basic with a D600.
Thank you
Benjamin
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joedfelipe on January 31, 2014, 11:32:53 AM
Hi Phil!

This has been an old thread but I'm still desperately finding solutions to my problem :'(. It seems that I'm also experiencing this kind of problem after viewing and rating my Nikon D7000 NEFs in an old version of ViewNX2 directly from the SD card. Only rated images have been 'corrupted' so far. I think this tool (fix_corrupted_nef) would help but it doesn't support the Nikon D7000. Can you make this tool also available for the D7000? I would really appreciate that. Thank you so much!  :)

Joed
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 31, 2014, 11:44:23 AM
Hi Joed,

I can implement support for the D7000 if you supply me with a full test set of 8 NEF images.  4 original images and 4 corrupted images with these settings:

1) 12-bit lossless compressed
2) 12-bit compressed
3) 14-bit lossless compressed
4) 14-bit compressed

You can either email these to me (philharvey66 at gmail.com), or upload them to a file sharing utility for me to download.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 03, 2014, 07:52:05 AM
I got the samples, thanks.

This is not the same problem as the one solved by the fix_corrupted_nef utility.

The metadata for the corrupted image looks fine as far as I can tell (which is what fix_corrupted_nef fixes).

Instead, the raw image data is truncated in the corrupted image you sent, and 3791 bytes are missing.  The raw data is right at the end of the file, so presumably you could just add 3791 bytes to the end of the file and recover most of the raw image.

Also note that even the "original" NEF images you sent were modified by ViewNX 2.0.  This is bad (because Nikon software has a long history of corrupting NEF images and Nikon will give you no support when this happens).  You need to find a download technique that doesn't mess with your files.  I recommend avoiding the Nikon and Windows download utilities since they modify the files.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joedfelipe on February 03, 2014, 03:59:17 PM
Phil,

Thanks for taking time processing my samples. If that's the problem, how can I add 3791 bytes to the end of the file? I really don't have any idea on how to do that :(

Btw, I only used copy and paste from my SD card directly to my macbook pro then view it in ViewNX2 (I didn't use Nikon Transfer to download my files. Can the ViewNX 2 modify the image too just by viewing RAW images from it?

Joed
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 03, 2014, 06:31:15 PM
Hi Joed,

To add random bytes to the end of the file, on a Mac you can do this from the Terminal:

cat ANYFILE >> test.nef

where ANYFILE is any file that is at least 3791 bytes long.

Apparently ViewNX2 writes to the image when you just look at it:

> exiftool -software .
======== ./corrupted 14-bit lossless compressed.NEF
Software                        : ViewNX 2.0 M
======== ./original 12-bit compressed.NEF
Software                        : ViewNX 2.0 M
======== ./original 12-bit lossless compressed.NEF
Software                        : ViewNX 2.0 M
======== ./original 14-bit compressed.NEF
Software                        : ViewNX 2.0 M
======== ./original 14-bit lossless compressed.NEF
Software                        : ViewNX 2.0 M
    1 directories scanned
    5 image files read


Bad, bad software.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Alan Clifford on February 04, 2014, 08:12:49 PM
Quote from: Phil Harvey on February 03, 2014, 06:31:15 PM

Apparently ViewNX2 writes to the image when you just look at it:


Phil, that is not something I have been experiencing.

======== ./AHC_6325.NEF
Software                        : Ver.1.04
======== ./AHC_6325_cr.NEF
Software                        : ViewNX 2.8 M
======== ./AHC_6325_cr2.NEF
Software                        : ViewNX 2.8 M
======== ./AHC_6326.NEF
Software                        : Ver.1.04
======== ./AHC_6327.NEF
Software                        : Ver.1.04
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 05, 2014, 07:36:20 AM
Hi Alan,

That is useful information.  Maybe something else is happening then.  (I know it isn't me because I haven't run ViewNX.)

You two are running different versions of ViewNX though.  It's a long shot, but could this be the difference?

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Alan Clifford on February 05, 2014, 05:46:22 PM
I wouldn't like to comment re: the versions.  But I've used that version with the D7000:

======== dsc_0108.nef
Software                        : Ver.1.00
======== dsc_0108_crop.nef
Software                        : ViewNX 2.0 M

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: kohnecamera on March 11, 2014, 09:54:13 AM
Hello, I am very novice when it comes to terminal commands on the mac. I am attempting to use this, but when i drag and drop the file(s) that i need to fix, i receive a permission denied error. I am the admin user, I've changed read and write permissions within the "get info" window, but still have this problem. Any help or ideas would be greatly appreciated!
Thanks
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: kohnecamera on March 11, 2014, 10:18:34 AM
Quote from: kohnecamera on March 11, 2014, 09:54:13 AM
Hello, I am very novice when it comes to terminal commands on the mac. I am attempting to use this, but when i drag and drop the file(s) that i need to fix, i receive a permission denied error. I am the admin user, I've changed read and write permissions within the "get info" window, but still have this problem. Any help or ideas would be greatly appreciated!
Thanks

I've fixed my own problem! As usual, one must read the instructions carefully before use. Thanks again for a great program!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: didier on June 17, 2014, 06:20:24 AM
Hello Phil, iam new here from France.
I got problems with my RAW (NEF) files with my DF Nikon during transferring to my computer.
I will try with your application to restaure my files, i know that it works with the d800 and d4, d600.
Is it working with the new DF ? (df mix of d600 and the d4 captor)
Thanks a lot.
Didier.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 17, 2014, 11:22:26 AM
Hi Didier,

No, it doesn't yet work with the DF.  To add support for this, I will need corrupted and uncorrupted images from each of the possible NEF formats written by this camera (all combinations of compression settings and NEF bit depth).  If you email the samples to me (philharvey66 at gmail.com) I will add support for this camera.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Cactus on August 13, 2014, 01:35:44 PM
Quote from: Phil Harvey on June 17, 2014, 11:22:26 AM
Hi Didier,

No, it doesn't yet work with the DF.  To add support for this, I will need corrupted and uncorrupted images from each of the possible NEF formats written by this camera (all combinations of compression settings and NEF bit depth).  If you email the samples to me (philharvey66 at gmail.com) I will add support for this camera.

- Phil

Hi Phil, hi Didier,

great success with D800 (thank very very much!) but the same problem with the Df. Would be really fine if exiftools would help.

Thanks again,
Peter
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 15, 2014, 07:08:38 PM
Hi Peter,

If you email me the samples, I will add support for this.  (It will take a few weeks though, because I am still technically on vacation now.)

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: kimequa on January 05, 2015, 02:17:13 AM
Phil,
I'm not sure if your software is what I need or not. I'm sure you'll know after I explain my problem.

I have the Nikon D7000 camera. I was unaware that I needed a specific compatible memory card, so I bought a cheapo one before my vacation. About half the photos (.nef) and videos (.mov) look great and the other half are corrupted and I cannot see them at all. I have already re-used the memory card a number of times since then (I was on vacation, so every day I uploaded them to my PC) ....but I DO have the corrupted nef files saved on my PC in hopes that I may one day find a fix.

Do you think it's possible to recover any of these using your software or something else?? I did try using your program, but I got an error that says "Not a D4, Df, D600, D610, D750, D800/D800E, D3200, D5200, or D7100 NEF"

Thank you for your help!!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 05, 2015, 06:56:39 AM
My guess is that the images are gone for good, but if you are lucky you may be able to extract JPG previews from the garbled data.  See this thread (https://exiftool.org/forum/index.php/topic,4172.msg19805.html#msg19805) for a script and instructions on how to do this.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Ann on February 24, 2015, 11:37:03 AM
Hi Phil,

This is all very interesting, thanks! We just realized that lots of our NEF files from Nikon D4s have been corrupted after importing them through Nikon Transfer 2.
Will there be a version that will support and can repair NEF files from the D4s?

Thank you for your help!

Ann
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 24, 2015, 11:39:35 AM
Hi Ann,

If you send me the necessary samples (see here (https://exiftool.org/forum/index.php/topic,4220.msg24236.html#msg24236)), then I will add support for the D4s.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Ann on March 09, 2015, 06:06:31 AM
Hi Phil,

Thank you so much, I have sent you the files.

Ann
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on March 09, 2015, 08:19:12 AM
Hi Ann,

I got the samples.  This is not the same type of corruption as that corrected by fix_corrupted_nef.  But I have seen a similar problem before with some D810 images (https://exiftool.org/forum/index.php/topic,6348.msg31465.html#msg31465).

With your images, it seems that only SubIFD2:CFARepeatPatternDim may be messed up.  The following command fixes this if necessary.  Please try this command on some of your corrupted images and let me know how it goes.

exiftool -subifd2:cfarepeatpatterndim="2 2" -if "$cfarepeatpatterndim eq '512 512'" FILE

where FILE is the name of one or more corrupt images or a directories containing corrupt images.  (The above quoting is for Windows.  Exchange the single and double quotes if you are on Mac or Linux.)

I think this should fix 5 out of the 6 samples you sent.  However, one seems to have more problems.  It looks salvageable, but it will be more work.  But before going to the extra effort, I want to see how the command works on your files.

- Phil

Edit: fixed missing "-" on -if option
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Ann on April 07, 2015, 10:35:42 AM
Thanks a lot Phil. I tried the command on a few corrupted images and it seems to be working.

Ann
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Ann on April 20, 2015, 08:09:56 AM
Hi Phil,

I have tried the command on a larger number of corrupted files now and it seems to be working on some of the files but not all. It seems to be working on the files shot with the D4s and not on the ones shot with a D810. Do you have a command for the D810 too or could it be a different kind of problem? Thank you so much for your help, very much appreciated!

Ann
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on April 20, 2015, 08:13:56 AM
Hi Ann,

Could be a different problem.  Send me a sample and I'll take a look.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on April 20, 2015, 09:36:24 AM
Hi Ann,

I got the sample.  I don't see anything obviously wrong with the metadata in this image.  Also, it seems to open just fine in Apple Preview and Nikon View NX2.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Ann on April 20, 2015, 09:52:16 AM
Hi Phil,

Yes that works for me too however I can't open it in Nikon Capture NX2 (version 2.4.7), which now works for the other files (D4S). Any ideas?

Thanks,
Ann
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on April 20, 2015, 09:59:42 AM
Hi Ann,

Sorry, I don't have any other bright ideas.  If Nikon software support was any help at all I would suggest asking them. :(

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Alan Clifford on April 20, 2015, 12:50:48 PM
The D810 is not supported by capture nx2.

This page might be of interest:

http://nikonrumors.com/2014/10/25/another-alternative-solution-how-to-edit-nikon-d810-nefraw-files-with-capture-nx2-raw2nef-software.aspx/
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on April 20, 2015, 06:16:51 PM
Quote from: Alan Clifford on April 20, 2015, 12:50:48 PM
The D810 is not supported by capture nx2.

Wow.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Hayo Baan on April 21, 2015, 02:28:15 AM
Quote from: Phil Harvey on April 20, 2015, 06:16:51 PM
Quote from: Alan Clifford on April 20, 2015, 12:50:48 PM
The D810 is not supported by capture nx2.

Wow.

NX2 is dead, you'll have to use the new NX-D. I used to like NX2 quite a lot, but I've now switched to Adobe Camera Raw completely (NX-D just didn't work for my worklow). My productivity has actually gone up tremendously since then, so I'm glad I made the switch.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Genex73 on May 09, 2015, 06:54:10 PM
I did want to drop by and thank you for the Nef Repair tool. I help out in the Adobe Photoshop forums and while I personally don't have this problem, I was able to get someone to your site to download it for the Mac and repair his D800 nefs.

Thanks for the great work.

Gene
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on May 09, 2015, 07:56:37 PM
Hi Gene,

Excellent.  Good job.  Thanks for the note.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joostkrebbers on June 05, 2015, 07:36:58 AM
Phil,

Apparently the tool is not working for corrupted nefs from the Nikon D3; is it possible to make the tool work for the D3?

If so, highly appreciated.


Joost
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 05, 2015, 08:08:58 AM
Hi Joost,

How was the D3 image corrupted?  If it was corrupted by Nikon software, then send me a sample and I'll take a look.  My email is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 05, 2015, 11:07:35 AM
Hi Joost,

I got your image.  I has been edited by both Nikon Capture NX and PhotoMechanic.  The only thing I see obviously wrong are the X/YResolution tags in the SubIFD (the full-sized preview), but this shouldn't be a big problem.  Everything else looks OK, and I can open the NEF without a problem using Apple Preview and Nikon Capture NX-D.

What software are you using that doesn't display this image correctly?

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joostkrebbers on June 06, 2015, 08:45:26 AM
Hi Phil,

Thnx for your quick reply! I am using Capture 1 version 8.3 for mac and have a whole bunch of images previously edited with NX2 which don't display correctly in C1.


Rgrds. Joost 
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 06, 2015, 11:38:33 AM
Hi Joost,

I recommend complaining to Nikon.  They really need to work the bugs out of their software.

But as for what is causing C1 to have problems, I couldn't say for sure.  The way to figure this out would be to take an NEF, run it through NX2, then use ExifTool to compare the metadata (exiftool -a -G1 FILE).  Then, use ExifTool to change things one at a time or in groups until you figure out what was causing the problem.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joostkrebbers on June 08, 2015, 09:24:50 AM
Hi Phil,

I would certainly complain if there would be a chance that Nikon would be listening but that's what I don't expect with a piece of aborted software. It is actually quite easy to determine what information has been added by NX2 but I have troubles to understand how I can delete that with Exiftool. I have found ExiftoolGui which is unfortunately too limited. Please can you explain me in a simple way how to delete the NX2 information(which is mainly in the makers notes)? It was by the way way my understanding that the utility "fix corrupted nef's" was more or less doing that for the more recent Nikon camera's?


Rgrds. Joost
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 08, 2015, 09:34:44 AM
Hi Joost,

As-is, ExifTool will not delete parts of the maker notes.  The reason for this is to avoid incompatibilities with manufacturer software.  If you really want to do this, you would need to create a user-defined tag for the MakerNotes tags you want to delete, with the Permanent flag set to 0 in each of your tag definitions.

The fix_corrupted_nef utility didn't mess with the maker notes.  It repaired damage done to the tags in SubIFD1, not the maker notes.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: joostkrebbers on June 10, 2015, 07:29:03 AM
Hi Phil,

I just checked the fix corrupted nef utility on a corrupted D800E nef and it apparently does not solve the problem with Capture 1 (I had the impression that it would); strange is that any other raw converter has no problem reading and properly displaying the corrupted nef. So, it seems Capture 1 specific. For now I will contact Phase One and find out whether they will be able and prepared to fix it.


Thanks and best regards, Joost
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on August 03, 2015, 08:49:25 PM
Hi Joost.

I don't know if this is of any help, but in the past I experienced troubles between photomechanic and Nikon's Capture NX 2, which boiled down to one singular entry left by photmechanic, a tag which if I recall right is called or contains "endoffilepreferences".

One way of getting rid of this entry is via Photomechanic itself.
"Use the Delete Metadata command on the Tools menu to delete the 'Photo Mechanic end of file preferences'."

I read that other software, even some web services, had troubles with this tag too, so I reckon Aperture might have the same troubles :P


Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: spark on August 03, 2015, 08:58:04 PM
Hi Phil,

it's been a while since I had a look at this thread and must say... WOW!
You put great effort into this project and potentially helped god knows how many people with your fix! (Have you actually any idea how many?)

Thanks for your efforts and eagerness to help, I'm happy to see that others could be helped too :)
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 05, 2015, 07:28:21 AM
Hi Spark,

Yes.  This problem has affected various other Nikon models and many Nikon owners.  I have no way to tell how many people have benefitted from fix_corrupted_nef, but the numbers were significant, and some people were able to rescue some images that were very important to them.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: wengee on January 03, 2016, 10:44:58 PM
Hi Phil
Another innocent caught out by using old Nikon Software (and of course I didn't read right through to page 59 of the manual where it coyly warns that 'using an earlier version may fail to transfer RAW files correctly' partway down the page. You'd think they might have it in big bold type right on the front page by now?) Does your software work with NEF files from the D5300? I tried downloading the software but it didn't seem to do anything. Generated a new folder, but nothing in it.
Did I use it wrongly (quite possible, I can use the computer OK, but know nothing of programming etc, sorry), if not, is there something I can do to get a version that will work?
I have over a thousand corrupted RAW files from my (at the time, brand new) D5300, from a 'once in a lifetime' trip around the UK, and visited a number of places specifically for the photo opportunities. I would very much like to be able to use them!
Thanks for any help.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: TorC on January 04, 2016, 12:34:42 AM
Wengee, while I've never been caught because I've never had reason to touch Nikon's software with a barge pole, it looks like the 5300 is a new camera to the Nikon software corruption.

Check this post (https://exiftool.org/forum/index.php/topic,4220.msg22342.html#msg22342) in the thread for details on what Phil probably needs to update the fix_corrupted_nef tool.  Duplicate that for all high-speed crops you need it for (and future users would appreciate if you made a complete set regardless).

Edit to add:  Not sure about the 5300, but some cameras appear to have obscure high speed crop sizes when used in movie mode for live view stills.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on January 04, 2016, 07:41:55 AM
Send me a corrupted sample and I'll take a look to see if it can be fixed (philharvey66 at gmail.com).  If it can, then I'll need a full set of samples to add support for this version (explained in the thread that TorC linked).

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 12:29:20 PM
Hi Phil!

I was trying to use your software but noticed that Nikon d4s nefs are not supported.

Images we shot from our wedding seem to be corrupted.

Thank you!

William

Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 17, 2016, 12:31:51 PM
Hi William,

If they were corrupted by Nikon software, then send me one of the files and I'll see if it is possible to fix with this utility.  If so, then I will require more samples shot at various compression settings to be able to add support.  My mail is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 12:43:45 PM
Hi Phil,

Thanks for your response. I'm sending you the file via wetransfer.

We had been working with Nikon applications. If that's not the problem would you have recommendations?

Best,

William
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 17, 2016, 01:00:52 PM
Hi William,

I got the image, but it isn't the type of problem that is fixed by the fix_corrupted_nef utility.  To me, the file data looks OK, but it seems that the raw data is at least partially corrupted.  However, the good news is that the full-sized JPEG images may be recovered using ExifTool with this command:

exiftool -w %d%f_preview.jpg -jpgfromraw -b DIR

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 01:28:37 PM
Wow! Thanks Phil. The Jpegs are extracting perfectly!

Do you see anyway that the Raw data could be recovered? Also, have you heard of Adobe Lightroom or Adobe Bridge corrupting files?

The first time that we experienced corruption is when we opened these files in Bridge and Lightroom.

Thanks a million,

William
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 01:35:26 PM
Hi Phil,

Actually I'm noticing that many of my nefs in multiple folders across multiple drives have this corruption. Can corruption spread like a virus? I'm sorry if I'm bugging you with this... I've just never seen corruption happen like this.

Best,
William
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 17, 2016, 01:38:20 PM
Hi William,

I haven't heard of NEF corruption due to Adobe software.  Nikon software is another story, but I haven't seen corruption like this from any software -- only due to disk problems, but apparently this isn't your situation.  Are the modification timestamps on the files recent?  If so, what software touched the files?  Also, do you have any antivirus software which could have potentially interfered with the writing of these files?

I doubt that it would be possible to recover 100% of the raw data.  Recovering more than you see now may be possible, but would probably be some work.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 02:08:07 PM
Hi Phil,

We don't have any anti-virus software. We work on a Macpro and a Macbookpro.

The short of it is that we purchased a G-tech 4tb Raid Drive to use a central working drive. We upload our photo work to it and about 3 months in the drive started having issue mounting and ejecting. We send it in the manufactor and received a refurbished replacement.

It was when we started using this replacement drive that we started noticing the corruption of Nefs.

Since then, we've received 3 hard drives from HGST and each time the folders and files from the original drive are uploaded the drive starts performing strangely.

We're not sure how many files are corrupted, as there are a lot of volumes to search though and we've been concerned about spreading any issues, but so far it only seems to be Nefs across multiple folders.

Best,

William
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 02:20:10 PM
The corruption is really wide spread. Effecting Jpegs, Psd, nefs, etc.

It almost seems like the corruption worsens when I preview the files.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 17, 2016, 02:48:52 PM
To add on to my last comment:

I'm also really confused because the files that are on my newest replacement are corrupted, where as the same files from the drive I transferred them from appear to be intact.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 17, 2016, 09:07:01 PM
This sounds very scary.  I hope you can isolate this problem.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: williamwalsh on February 18, 2016, 01:48:57 PM
Hi Phil,

Yeah, it's really scary. :o Thanks for the help!

Blessings,

William
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: drjazz on May 31, 2016, 03:03:59 PM
Hi Phil -

is there a chance that you update this program to work on D5 NEFs...?
I didn't use ViewNX2 software but Windows Teracopy with a new (never used before) CompactFlash Card adapter - I ended up with a 200+ mutilated NEFs. I can display them - they have color streaks and pixel shift - and they can even be converted to DNG. However the DNG shows the same errors...
Would your software work wonder...?

Thank you very much!
Regards
Ueli
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on May 31, 2016, 04:31:22 PM
Hi Ueli,

If you send me one of the corrupted images I'll take a look to see what can be done.   My email is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on June 01, 2016, 07:49:45 AM
Hi Ueli,

I got the files you sent.  As you said, there is some corruption of the raw data.  The metadata is almost completely intact, but unfortunately there are also some problems in the data for the preview images.  These NEF files store 4 embedded images:


SizeTypeTag
5568x3712JPEGJpgFromRaw
1620x1080JPEGOtherImage
640x424JPEGPreviewImage
160x120TIFFThumbnailTIFF

You can use the following command to extract all of these:

exiftool -preview:all -b -W %d%f_%t%c.%s DIR

Unfortunately there is some corruption of the larger embedded images (JpgFromRaw and OtherImage) in the files you sent.  The smaller images (PreviewImage and ThumbnailTIFF) seem intact.

I know of no way to easily recover from minor bit errors like this.  The best I can suggest is to try to extract the embedded images from all of your NEF's, and if you are lucky maybe some of the large ones are still intact.

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: drjazz on June 01, 2016, 11:39:48 AM
Hi Phil -

that's cool! Thank you very much for your effort...
I'll give it a try!!
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: cpaulPHL on August 23, 2016, 11:01:30 AM
Slightly different problem here - Nikon NEF files that were edited with Capture NX 2 can be displayed in View NX 2, but can no longer be converted ("unsupported file type").
Many of these NEF files were created with a Nikon D60, which isn't supported in the "fix_corrupted_nef" utility.
Any idea what Capture NX 2 might be doing to "corrupt" these NEF files? I tried removing all adjustments and SAVE AS in NX 2 but no luck...

Thanks in advance!
- Paul

Quote from: Phil Harvey on February 17, 2016, 12:31:51 PM
Hi William,

If they were corrupted by Nikon software, then send me one of the files and I'll see if it is possible to fix with this utility.  If so, then I will require more samples shot at various compression settings to be able to add support.  My mail is philharvey66 at gmail.com

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on August 28, 2016, 11:08:57 AM
Hi Paul,

The usual thing that goes wrong is the RAW data IFD is converted into one for a JPEG preview.  The raw data is still there in place of what should be the JPEG image.  You can check to see if this is the case by comparing the tags in SubIFD1 between a good and bad image:

exiftool -a -subifd1:all FILE

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: nikonnewbie on February 13, 2023, 11:34:34 PM
Hi - would it be possible to add MD5 and/or SHA1 checksums for the  "fix_corrupted_nef_win.zip" file? Perhaps just add it to the same page for the regular ExifTool? Thx. Apologies in advance if it is already posted somewhere I didn't see yet.

thanks so much.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 14, 2023, 06:55:44 AM
Here they are.  I don't know if I like them on the main ExifTool page.

SHA1(fix_corrupted_nef-3.2.zip)= be8dc602c6508699667ceb2f10862bed9cf514f2
SHA1(fix_corrupted_nef_win-3.2.zip)= 8e64caf8a66a7608c910621ce03af8a2742a441d

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: nikonnewbie on February 14, 2023, 09:57:43 PM
Hi thanks so much! I have a quick follow up question.

On https://sourceforge.net/projects/exiftool/files/ I see the files:

fix_corrupted_nef_win-3.3.zip
fix_corrupted_nef-3.3.zip

From https://exiftool.org/fix_corrupted_nef.html the files are:

fix_corrupted_nef_win.zip
fix_corrupted_nef.zip

I checked the Mac/Linux versions and they match each other (presumably version 3.3) but it does not match the version you mentioned (version 3.2). Is 3.3 the latest version? If so, would you mind providing those checksum?

Thanks again in advance.
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: Phil Harvey on February 15, 2023, 06:46:55 AM
Sorry, you're right.  The current version doesn't have a version number on the ExifTool web site. Here are the sha1 hashes for these files:

SHA1(fix_corrupted_nef.zip)= 72a0135f7cebd1909c657495dc501d02407be5b9
SHA1(fix_corrupted_nef_win.zip)= 10d1423c79eade0a61270210b73d4aaade0b98c6

- Phil
Title: Re: Nikon D800 NEFs ==> SubIFD Tags corrupted ==> Rewrite possible?
Post by: nikonnewbie on February 17, 2023, 09:41:24 PM
Hi, thank you again for that, it now matches for me.

I have some older NEF files which I could not view a thumbnail or open and view with any application and I found your utility which I was hoping would help. I know at the time I used the Nikon software to transfer and edit some of the photos I took back then.

The tool gave me an error (file format error) so I used ExifTool to display the tag info and it gives me an error for these files, "Entire file is binary zeros"  ??? . So I just used a the command XXD to dump out the files in hex and binary and they are indeed, zeros. So I have no idea what may have happened. Fortunately, it's not too many of them.

This did, however give me an opportunity to learn a LOT more about the ExifTool itself!

Thanks again for your quick replies.