Nikon NEF

NEF files are generated by Nikon cameras.

MIME type

image/x-nikon-nef

Organisation

It is a TIFF file. close to TIFF/EP or DNG.

Thumbnails

NEF files have a large JPEG preview. It is either in a subIF of the main IFD (type == thumbail) or for the older, in the MakerNote IFD.

Compression

D1 files are not compressed.

D1x files are not compressed but have a weird shape: they have a pixel ratio of 0.5, ie 2 row for one.

Some files are packed (Compression = 32769). It is a standard packing with some padding: if col % 10 == 9, then an extra 8 bits must be skipped.

Compression (Compression = 34713) is a Huffman tree and a quantization table. The quantization tables are at 0x8c and 0x96 tag from the MakerNote. Strangely dcraw seems to only use the later as it override the value reading the tags in sequence. See nikon_compressed_load_raw().

http://www.majid.info/mylos/weblog/2004/05/02-1.html has a very insightful article about NEF decoding.

The D100 has a bug that tag uncompressed image as compressed, but not always. See nikon_is_compressed() in dcraw.c. It appear that most D100 will just use uncompressed (packed) as the compression froze the camera for 20s