larger image dimensions for NEF files

Started by royhodgman, April 16, 2013, 11:46:18 PM

Previous topic - Next topic

royhodgman

When I use exiftool to extract image dimensions from NEF raw files, I get values that are larger than is specified in the documentation for the camera, and larger than the values for the same picture saved as a JPG in the camera.

I have a Nikon D7000, and according to the specifications listed on Nikon's website (http://www.nikonusa.com/en/Nikon-Products/Product/Digital-SLR-Cameras/25468/D7000.html#tab-ProductDetail-ProductTabs-TechSpecs), the camera produces large images that are 4928 pixels wide and 3264 pixels high.

Exiftool reports the expected dimensions for JPG files right out of the camera, but reports 4992x3280 as the dimensions for NEF files.

For example, after setting the camera to save both NEF and JPG files, I took a picture of the wall next to me. The NEF and JPG versions of that picture directly from the camera are here:

https://www.dropbox.com/s/qdee0gttr6u2ikj/DSD_0850.JPG
https://www.dropbox.com/s/1hz6syjkyqwok0u/DSD_0850.NEF

When I run the following command:

exiftool -ImageWidth -ImageHeight -ImageSize DSD_0850.JPG DSD_0850.NEF

I get the following output:

======== DSD_0850.JPG
Image Width                     : 4928
Image Height                    : 3264
Image Size                      : 4928x3264
======== DSD_0850.NEF
Image Width                     : 4992
Image Height                    : 3280
Image Size                      : 4992x3280
    2 image files read


The dimensions for the JPG file are as expected, but the width in the NEF file has an extra 64 pixels, and the height has an extra 16 pixels.

Why does this happen?

Interestingly, a similar problem is present in ImageMagic's identify command.

When I run

identify DSD_0850.JPG DSD_0850.NEF

I get the following output:

DSD_0850.JPG JPEG 4928x3264 4928x3264+0+0 8-bit sRGB 918KB 0.000u 0:00.000
DSD_0850.NEF=>/var/tmp/magick-58371SEV12c2zqvm.png[1] NEF 4948x3280 4948x3280+0+0 16-bit sRGB 81.04MB 0.000u 0:00.000


Here again the JPG is identified with the expected dimensions, but the NEF now has an extra 20 pixels in the width and an extra 16 in the height.

Finally, OS X's build in sips tool shows both images as having the same size:

sips -g pixelWidth -g pixelHeight DSD_0850.JPG DSD_0850.NEF

produces:

./DSD_0850.JPG
  pixelWidth: 4928
  pixelHeight: 3264
./DSD_0850.NEF
  pixelWidth: 4928
  pixelHeight: 3264


So what's going on here? How can I help fix this?

Phil Harvey

#1
ExifTool reports the size of the full-resolution image (the RAW image stored in SubIFD1 of the NEF file).  This image includes a border of masked pixels which are used for the black-level correction.

dcraw reports this for a D7000 NEF:

Thumb size:  4928 x 3264
Full size:   4992 x 3280
Image size:  4948 x 3280
Output size: 4948 x 3280

Offhand, I don't know how it determines the dimensions of the actual imaging area.

    - Phil

Edit:  Looking a the source code for dcraw, I found how it does this for the D7000:

  } else if (!strcmp(model,"D5100") ||
     !strcmp(model,"D7000")) {
    width -= 44;


There are roughly 1500 lines of similar code in dcraw.c for other models.  Nasty.
...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 ($).

royhodgman

Nasty indeed. Thanks for the explanation.