Author Topic: Corrupted .nef files  (Read 2748 times)

Montagnard65

  • Newbie
  • *
  • Posts: 5
Corrupted .nef files
« on: December 01, 2016, 02:05:34 AM »
Hi there,
It seems Exiftool could solve my problem but I don't know how... I try some commands, read in others thread, but of course without understand, it doesn't works...
Anyway, this is my problem :
During a saving, 95% of my nef files were corrupted (and some jpeg ; so, thousands of my pictures are unreadable... :-( ) and I realised it after deleting the originals... The size of the pictures are the same than it should, and when I open a corrupted nef with an hexa reader, I can read some information, but the header is unreadable by exiftool.
Do you some tips to solve it ?

Thanks !

PS : sorry for my bad english...

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Corrupted .nef files
« Reply #1 on: December 01, 2016, 02:17:41 AM »
Can you share a sample image so we can have a look?
(a nef file will be too big to post here, but you can use e.g. a transfer service to store it and share the link here)
Hayo Baan – Photography
Web: www.hayobaan.nl


Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Corrupted .nef files
« Reply #3 on: December 01, 2016, 03:49:23 PM »
I took a look at the files and if they are both from a D90 then I'm afraid the bad one is corrupted beyond recovery :(
I did see a lot of data that seemed recognisable, but not a “file start” I recognised.

On a positive note, with Phil's extract preview script (@Phil, you should really put this somewhere on your home page ;)), I was able to extract a 4288x2848 pixel preview from the file (a B&W photo of two boys)!

So, while the original seems unrecoverable to me (but perhaps Phil can do some more magic than me), you at least can recover the JPG from this file, so hopefully from the others as well.
Hayo Baan – Photography
Web: www.hayobaan.nl

Montagnard65

  • Newbie
  • *
  • Posts: 5
Re: Corrupted .nef files
« Reply #4 on: December 01, 2016, 04:35:26 PM »
Hi Hayo,
I tried the script but it told me :
Code: [Select]
This scripts requires Image::ExifTool -- please install it.
I'm not sure to understand what it needs because Exiftool is installed :
Code: [Select]
MacBook-Pro-Benjamin:~ benjamin$ exiftool -ver
10.36

What is missing ?

OK, if Phil could do a tricks to get back my nef file, it will be awesome, but if I can get back a high resolution jpeg it's already very good !

For my culture, in my case, flags of header are probably broken, but if I rebuilt a basic header, do you think I can get back the nef file ?

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Corrupted .nef files
« Reply #5 on: December 01, 2016, 05:54:01 PM »
To be able to use Phil's script you need to install the full Perl version of exiftool, not just the executable. On Windows this also means you have to install a version of Perl. ActivePerl is one of the versions I'd recommend in that case. If this gets too complicated, I'm very much willing to do the conversion for you if you can point me to a place to download your nefs.
Hayo Baan – Photography
Web: www.hayobaan.nl

Montagnard65

  • Newbie
  • *
  • Posts: 5
Re: Corrupted .nef files
« Reply #6 on: December 03, 2016, 03:58:40 AM »
Thanks Hayo for your help, I will try first to do it by myself, but I'm not sure what I have to do :
- Where can I find the full Perl version of Exiftool ? And how can I Install it (I'm a mac user) ?

Have a good week end!

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Corrupted .nef files
« Reply #7 on: December 03, 2016, 04:07:02 AM »
Since you're on a Mac, it's pretty easy to install the full thing. The first download link on the main page gives you the tar.gz file you need. Then just follow the instructions for the full unix install (this requires the XCode command line tools to be installed which you may not have, so install these first (free from Apple)).

Good luck :)
« Last Edit: December 03, 2016, 04:18:00 AM by Hayo Baan »
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: Corrupted .nef files
« Reply #8 on: December 03, 2016, 09:26:51 AM »
An alternative is to just add this line to your script before "use Image::ExifTool;":

BEGIN { push @INC, '/usr/local/bin/lib' }

(since the ExifTool libraries are installed in that directory by the Mac package)

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

Montagnard65

  • Newbie
  • *
  • Posts: 5
Re: Corrupted .nef files
« Reply #9 on: December 05, 2016, 03:52:07 PM »
Wahoooo !! It's awesome, I tried with some of my corrupted pictures and it works ! Thank you very very much both of you!! :-)

Phil, if I may abuse, could you have a look on my corrupted picture, to see if I really can't get back a useful stuff ? It could be magical if I can have a picture with more "details" for touch up. If you have no time to have a look, no problem, could you only advise me on "literature" which explain how are built the .nef files (flags, headers, etc) ?

Thanks again for your great job !

Benjamin

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16883
    • ExifTool Home Page
Re: Corrupted .nef files
« Reply #10 on: December 06, 2016, 07:44:03 AM »
Hi Benjamin,

I took a look at your file.  It seems to be part of an NEF file, and there is some metadata there.  I can fairly easily recover the date/time of the image (using strings FILE | grep -E "\d{4}:\d{2}"), but it would require some effort to extract anything else.  I don't have any automated tools that will help with files like this (other than the extract_preview script). 

The NEF files use a TIFF format.  Look at the TIFF 6 specification for details.

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