Corrupted NEF file repair for Nikon D5000

Started by NeilF, May 06, 2020, 09:40:03 PM

Previous topic - Next topic

NeilF

Hi Phil,

I was looking through an old drive with NEF files from a Nikon D5000, and I found many that are corrupted. Most likely they were corrupted by the use of Nikon transfer.  When I open the files in ViewNx-i, they have all the camera information and I can see the jpg preview, but the NEF file itself is corrupted.  I read in your Fix Corrupted Nikon NEF Images web page a reference to a post by someone who had the same problem with a D5000, but unfortunately that model is not listed as supported by your tool. Is it possible to add support for the D5000 in your fix tool?  I was able to find a good NEF file from that camera, so I can send you a good file and a bad file.

Thanks in advance,
Neil

Phil Harvey

Hi Neil,

Sure.  Send me the files and I'll see what I can do.  (philharvey66 at gmail.com)

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

Phil Harvey

I got the files.  Unfortunately, this doesn't look like a corruption by Nikon Transfer.  Those types of files have the SubIFD1:Compression changed from "NEF Compressed" to "JPG (old-style)".  But the SubIFD1 tags look good in the corrupted file you sent:

> exiftool -subifd1:all -a tmp
======== tmp/corrupted.nef
Subfile Type                    : Full-resolution image
Image Width                     : 4352
Image Height                    : 2868
Bits Per Sample                 : 12
Compression                     : Nikon NEF Compressed
Photometric Interpretation      : Color Filter Array
Strip Offsets                   : 1275368
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 1
Rows Per Strip                  : 2868
Strip Byte Counts               : 9655122
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
CFA Repeat Pattern Dim          : 2 2
CFA Pattern 2                   : 1 2 0 1
Sensing Method                  : One-chip color area
======== tmp/ok.nef
Subfile Type                    : Full-resolution image
Image Width                     : 4352
Image Height                    : 2868
Bits Per Sample                 : 12
Compression                     : Nikon NEF Compressed
Photometric Interpretation      : Color Filter Array
Strip Offsets                   : 1702756
Orientation                     : Horizontal (normal)
Samples Per Pixel               : 1
Rows Per Strip                  : 2868
Strip Byte Counts               : 10886644
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
CFA Repeat Pattern Dim          : 2 2
CFA Pattern 2                   : 1 2 0 1
Sensing Method                  : One-chip color area
    1 directories scanned
    2 image files read


And none of the Compression tags have been changed:

> exiftool -compression -a -G1 tmp
======== tmp/corrupted.nef
[IFD0]          Compression                     : Uncompressed
[SubIFD]        Compression                     : JPEG (old-style)
[SubIFD1]       Compression                     : Nikon NEF Compressed
[PreviewIFD]    Compression                     : JPEG (old-style)
======== tmp/ok.nef
[IFD0]          Compression                     : Uncompressed
[SubIFD]        Compression                     : JPEG (old-style)
[SubIFD1]       Compression                     : Nikon NEF Compressed
[PreviewIFD]    Compression                     : JPEG (old-style)
    1 directories scanned
    2 image files read


So I don't know if there is anything that may be done for these files. :(

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

NeilF

Thanks for looking into it. The problem must be somewhere else in the metadata. I attempted the procedure outlined in the blog post by Felipe Ceotto, the one referenced at the top of your web page, and it seems to work. After running the script, I can open the bad NEF file. The script seems to use your tool to do a brute force replacement of the metadata, so some of the original settings are overwritten, but at least the file opens.  I was hoping you'd be able to pinpoint exactly where the error was introduced in the bad file and devise an easy fix.

Neil

Phil Harvey

I'll take a look at this again when I get a chance.

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