/nikon_nef

a tentative to document the Nikon NEF file format and compression schemes

Primary LanguageC

Description of Nikon camera RAW formats : NEF and NRW

Version 0.31 (27apr2024)

(this is work in progress)

Introduction

Since 1999, some Nikon cameras can create files with RAW data, the first one being D1 with 12 bits compressed NEF files.

With D1X, lossy compression was added, and can be considered as "visually lossless". D70 was first non pro camera to offer NEF, but only lossy / compressed. 14 bits NEF were available in 2007 with D3 and D300.

Z9 and Z8 use new High Efficiency (HE) and High Efficiency* (HE*) compressions which is TinyRaw, and not supported yet by opensource libraw/DNGLab. https://onlinemanual.nikonimglib.com/z9/en/psm_raw_recording_94.html

NEF (Nikon Electronic Format) is from high end models, and NRW (Nikon RAW) for Coolpix, starting with P6000.

NEF and NRW are TIFF based formats.

https://www.nikonimgsupport.com/eu/BV_article?articleNo=000006125&lang=en_GB

N-RAW (NEV file) 12bits video

Support from open source projects

model release date format dcraw / libraw support
D1 06/1999 NEF 12bits uncompressed 1.49, 4apr2002
D1X 02/2001 12 bits, uncompressed or lossy compression 1.47, 29mar2002
D1H 02/2001 12 bits, uncompressed or lossy compression 1.57, 5may2002
Coolpix 5000 09/2001 NEF 12 bits uncompressed 1.69, 16oct2002
D100 02/2002 1.60, 20jun2002
Coolpix 5700 05/2002 NEF 12 bits uncompressed 1.64, 7aug2002
D70 01/2004 NEF 12 bits compression 1.167, 16feb2004
Coolpix 8400 09/2004 NEF 1.229, 21jan2005
D2X 09/2004 NEF 12 bits, WB decryption 1.250, 18apr2005
jpeg thumbs 1.368, 25feb2007
D3/D300 08/2007 NEF 12 or 14bits, compressed or lossless compressed 1.393, 8.78, 30oct2007, 14bits
split NEF 1.409, 11dec2008
Coolpix P6000 08/2008 NRW 12bits
D4S 02/2014 small RAW (yuv, NEFCompression = 8) 1.471, 23feb2015
D810 05/2016 small RAW
D6 09/2019 lossless (NEFCompression = 3) nikon_14bit_load_raw
Z50 12/2019
Z9 10/2021 NEF TicoRAW

Z9

- IFD#0 (22 entries)
  
  - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
  
  - ...
  
  - 0x014a, SubIFD (8 entries)
    
    - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
    - 0x0103, Compression = 6
    - 0x0201, JpgFromRawStart
    - 0x0202, JpgFromRawLength
    - ...
  
  - SubIFD#1
    
    - 0x00FE, SubfileType = 0 (Full-resolution image  )
    - 0x0100, ImageWidth = 8280
    - 0x0101, ImageHeight = 5520
    - 0x0102, BitsPerSample = 14
    - 0x0103, Compression = 34713 (0x8799)
    - 0xc7d5, NEFInfo (SubDirectory)
      - MakerNote (10 Entries)
  
  - SubIFD#2 (8 entries)
    
    - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
  
  - SubIFD#3 (14 entries)
    
    - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
    - ImageWidth = 384
    - ImageHeight = 256
  
  - SubIFD#4 (14 entries)
    
    - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
  
  - SubIFD#5 (14 entries)
    
    - 0x00FE, SubfileType = 1 (Reduced-resolution image  )
  
  - ExifIFD
    
    - MakerNote (72 entries)
      
      - PreviewIFD
        - 0x0103, Compression = 6
      - 0x0051 (24 bytes). Compression : "01010500" 00 00 **0e 00** 00 00 00 00 06 00 00 00 00 00 00 00 (https://exiftool.org/TagNames/Nikon.html#NEFCompression)

exiftool -a -H -u -v3 -g3 d:\raw_samples\z9\DSC_2999.NEF

https://exiftool.org/TagNames/EXIF.html

Compression

2002 - D100

12 bits compressed

2014 - Small RAW

with D4s (2014)

D3

uncompressed

  | + [SubIFD1 directory with 17 entries]
  | | 0)  SubfileType = 0
  | |     - Tag 0x00fe (4 bytes, int32u[1]):
  | |        2be6a: 00 00 00 00                                     [....]
  | | 1)  ImageWidth = 4288
  | |     - Tag 0x0100 (4 bytes, int32u[1]):
  | |        2be76: 00 00 10 c0                                     [....]
  | | 2)  ImageHeight = 2844
  | |     - Tag 0x0101 (4 bytes, int32u[1]):
  | |        2be82: 00 00 0b 1c                                     [....]
  | | 3)  BitsPerSample = 14
  | |     - Tag 0x0102 (2 bytes, int16u[1]):
  | |        2be8e: 00 0e                                           [..]
  | | 4)  Compression = **1**
  | |     - Tag 0x0103 (2 bytes, int16u[1]):
  | |        2be9a: 00 01  

D810

Nikon NEF Compressed

  | + [SubIFD1 directory with 17 entries]
  | | 0)  SubfileType = 0
  | |     - Tag 0x00fe (4 bytes, int32u[1])
  | | 1)  ImageWidth = 7380
  | |     - Tag 0x0100 (4 bytes, int32u[1])
  | | 2)  ImageHeight = 4928
  | |     - Tag 0x0101 (4 bytes, int32u[1])
  | | 3)  BitsPerSample = 12
  | |     - Tag 0x0102 (2 bytes, int16u[1])
  | | 4)  Compression = **34713**
  | |     - Tag 0x0103 (2 bytes, int16u[1])

lossy type 2

  | | | 43) NEFCompression = **4**
  | | |     - Tag 0x0093 (2 bytes, int16u[1])

lossless

  | | | 43) NEFCompression = **3**
  | | |     - Tag 0x0093 (2 bytes, int16u[1])

small

  | | | 43) NEFCompression = **8**
  | | |     - Tag 0x0093 (2 bytes, int16u[1])

uncompressed

  | + [SubIFD1 directory with 17 entries]
  | | 0)  SubfileType = 0
  | |     - Tag 0x00fe (4 bytes, int32u[1])
  | | 1)  ImageWidth = 7380
  | |     - Tag 0x0100 (4 bytes, int32u[1])
  | | 2)  ImageHeight = 4928
  | |     - Tag 0x0101 (4 bytes, int32u[1])
  | | 3)  BitsPerSample = 14
  | |     - Tag 0x0102 (2 bytes, int16u[1])
  | | 4)  Compression = **1**
  | |     - Tag 0x0103 (2 bytes, int16u[1])

lossy type 1

  | | | 34) NEFCompression = **1**
  | | |     - Tag 0x0093 (2 bytes, int16u[1])

D5

  | | | 16) SerialNumber = 3000234
  | | |     - Tag 0x001d (8 bytes, string[8]):
  | | |         3838: 33 30 30 30 32 33 34 00                         [3000234.]

  | | | 47) NEFCompression = **3**
  | | |     - Tag 0x0093 (2 bytes, int16u[1]):
  | | |         36c4: 03 00

  | | | 49) NEFLinearizationTable = F0.... .(...r^.....e.... ..-......X-P..
  | | |     - Tag 0x0096 (46 bytes, undef[46]):
  | | |         883c: 46 30 00 02 00 02 00 02 00 02 20 00 b7 28 aa 9d [F0........ ..(..]
  | | |         884c: e0 72 5e 90 1a f6 1e 99 65 82 f0 af bf 20 d2 d0 [.r^.....e.... ..]
  | | |         885c: 2d c8 c7 0c a1 84 c7 58 2d 50 d3 ab 00 00       [-......X-P....]

 | | | 56) ShutterCount = 15042
  | | |     - Tag 0x00a7 (4 bytes, int32u[1]):
  | | |         3730: c2 3a 00 00                                     [.:..]

Z50

  | + [SubIFD1 directory with 19 entries]
  | | 0)  SubfileType = 0
  | |     - Tag 0x00fe (4 bytes, int32u[1]):
  | |        460a6: 00 00 00 00                                     [....]
  | | 1)  ImageWidth = 5600
  | |     - Tag 0x0100 (4 bytes, int32u[1]):
  | |        460b2: e0 15 00 00                                     [....]
  | | 2)  ImageHeight = 3728
  | |     - Tag 0x0101 (4 bytes, int32u[1]):
  | |        460be: 90 0e 00 00                                     [....]
  | | 3)  BitsPerSample = 14
  | |     - Tag 0x0102 (2 bytes, int16u[1]):
  | |        460ca: 0e 00                                           [..]
  | | 4)  Compression = **34713**
  | |     - Tag 0x0103 (2 bytes, int16u[1]):
  | |        460d6: 99 87   

34713 = Nikon NEF Compressed

Z7_ii

packed 14 bits

  | | | 54) NEFCompression = 10
  | | |     - Tag 0x0093 (2 bytes, int16u[1]):
  | | |         880c: 0a 00      

2021 - Z9 - high efficiency - TicoRAW

References