Corrupt .NEF and .JPG File Question...

Started by kwray, July 29, 2023, 11:18:14 PM

Previous topic - Next topic

kwray

Greetings everyone,

I've been searching for an answer to my problem on the internet for about 2 weeks, but can't seem to locate one.

I was transferring photos from my SD Cards out of my Nikon 610 using my wife's card reader. She uses a different card and it seems that the SD Card connection I was using was bad. About half way through the transfer of ~800 photos (raw .NEF and large .JPG) the connection must have gotten wiggled and I got an error that the transfer had been interrupted by a disconnect. I've had this happen occasionally with an external drive or the camera, so I didn't anticipate it being a big problem. However, when I tried again, the card was empty. I put it back in the camera and, sure enough, everything was deleted. I tried again with a second card (not realizing that the card reader had an issue) and it happened with the second card.

Only a subset of the photos had not previously been saved, but these were pretty important photos, so I searched for an answer online. I discovered Disk Drill as a potential solution to recovering the files. I attempted it, but the free version has a restricted size limit and these files were very large. The files seemed to be recovered, but it would not let me preview them until I purchased, so I forked over the $84 and downloaded them. When I attempted to open any of the files I got the following error: "The file DSC_XXXX.NEF could not be opened. It may be damaged or use a file format that Preview doesn't recognize." I tried to open both the .NEF and .JPG files using several programs (including Nikon View), but nothing worked. I then attempted to zip the files to see if the info was really there and the zipped files from the raw images were of the same size.

I then looked for several options to solve how to "uncorrupt" the files (including ExifTool), but nothing seemed to work for this situation.

Yesterday, I decided to open some uncorrupted .NEF files in TextEdit. I then opened one of the corrupted files and noticed that several lines of code containing the exif data at the beginning of the "corrupted" file were missing. The lines seemed to be nearly identical for several uncorrupted files, except for the date the file was taken. I attempted to copy and paste this data (with the correct date found deeper in the code of the corrupted file) into the corrupted file an attempt to open it. This did not work, however.

When I was just about to give up. I decided to open some uncorrupted .JPG files and a corrupted .JPG. Similarly, the files seemed to just be missing a little code from the beginning of the corrupted file (though, the missing data was far less than in the .NEF files). I attempted to open the .JPG in Preview and Nikon View, but got the same error. By chance, I decided to try and open the new version of the corrupted file in Google Chrome and FireFox and BOOM! the photo appears just fine. However, this does me little good in Google Chrome/FireFox.

Can anyone fill me in to as 1) What's going on with these corrupted files?, 2) Why this seems to work for the .JPG, but not the .NEF files, 3) Why they open in an internet browser, but not a photo viewer, like Nikon View or Preview, and 4) How I can get these altered .JPG files into a file format that allows them to be opened into a photo program (i.e. save them as a different .JPG file)?

Thanks for any help, as I know this is outside the main focus of these forums.

Best regards,
Ken Wray

Phil Harvey

There is no utility that will fix arbitrarily corrupted raw images.  Some may be fixed by hand, but it depends on the details of the corruption and this must be done on a case-by-case basis so it is a lot of work.  However, the success rate is low.

The best bet is usually to extract any high-resolution JPEG images that may be still exist in the corrupted files.  My extract_preview script may be used for this.

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