ExifTool Forum

ExifTool => Newbies => Topic started by: Montagnard65 on December 01, 2016, 02:05:34 AM

Title: Corrupted .nef files
Post by: Montagnard65 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...
Title: Re: Corrupted .nef files
Post by: Hayo Baan 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)
Title: Re: Corrupted .nef files
Post by: Montagnard65 on December 01, 2016, 01:46:48 PM
Of course, thanks for your reply.
This is a good one :
https://share.mailbox.org/ajax/share/0ed76084084bcb43e97213584bcb4684bda66430869bf572/1/8/MzQ/MzQvMw
And this a corrupted one :
https://share.mailbox.org/ajax/share/01a85cf40570084d1e81d455700849edadef6a4b3997bbb6/1/8/MzQ/MzQvMg
Title: Re: Corrupted .nef files
Post by: Hayo Baan 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 (https://exiftool.org/forum/index.php/topic,4172.msg19805.html#msg19805) 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.
Title: Re: Corrupted .nef files
Post by: Montagnard65 on December 01, 2016, 04:35:26 PM
Hi Hayo,
I tried the script but it told me :

This scripts requires Image::ExifTool -- please install it.

I'm not sure to understand what it needs because Exiftool is installed :

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 ?
Title: Re: Corrupted .nef files
Post by: Hayo Baan 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.
Title: Re: Corrupted .nef files
Post by: Montagnard65 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!
Title: Re: Corrupted .nef files
Post by: Hayo Baan 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 (https://exiftool.org/Image-ExifTool-10.36.tar.gz) link on the main page (https://exiftool.org/) gives you the tar.gz file you need. Then just follow the instructions (https://exiftool.org/install.html#unix) 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 (https://developer.apple.com/xcode/))).

Good luck :)
Title: Re: Corrupted .nef files
Post by: Phil Harvey 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
Title: Re: Corrupted .nef files
Post by: Montagnard65 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
Title: Re: Corrupted .nef files
Post by: Phil Harvey 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