In this section you can find documentation about the existing RAW image formats.
- CR2, CRW (Canon)
- DCR (Kodak)
- DNG (Adobe)
- MRW (Minolta)
- NEF (Nikon)
- ORF (Olympus)
- PEF (Pentax)
- RAF (Fuji)
- SRF (Sony)
Generally speaking, RAW file formats are proprietary and not documented (with the exception of DNG Adobe, which is intentionally public), so one could expect that each is different from others. Indeed, most of them are (more or less strictly) based on the TIFF format, so we can divide them in two families:
- TIFF-based formats: CR2, DCR, DNG, MRW, NEF, ORF, PEF, SRF
- other formats: CRW
With "based on the TIFF" format we mean that they share the overall structure of IFDs and tags - but they are not necessarily "compliant" or "compatible" with TIFF.
Basic TIFF features
In this paragraph we are going to describe the main parts of TIFF that are useful for understanding TIFF-based formats (if you want to know more about TIFF, look at the specification (LINK HERE) - please note that the information below is precise for the purpose of decoding RAW file formats, but not necessarily in the TIFF perspective).
- Header. The header is a short sequence of bytes that can be found at the very beginning of the file. It contains a "magic cookie", that is a handful of bytes with a special value that "tags" the file as being a TIFF. Furthermore, the header also contains a flag value to specify the byte order convention (hi-lo or lo-hi), the format version and a pointer to the next data chunk.
- Tag. A tag is an elementary piece of information identified by an unique number (the code of the tag) which defined the meaning of the associated information. For instance, the code 256 means that the associated information is the width of the image. The information can be stored in many formats: integer from 8 to 32 bits, floating point, rational (an integer in form of n / d).
- Directory (IFD). A directory is a set of tags somewhat related among them. Each file contains more than a single IFD: one describes the main picture, others could describe various thumbnails, EXIF metadata, other kinds of metadata. Among these formats, the "makernote" is a special, proprietary block present in virtually all RAW file formats.
- Raster data. Raster data is the set of values that define the color of each pixel. There are many different layouts: the most commons are by strip (row by row) and by tile (adjacent square blocks). Often raster data is compressed (and the compression schema is almost always proprietary) and mangled (that is, it's arranged in a more complex way than necessary, probably to make the reverse engineer's life harder).
As we said before, the header points to the first IFD. Most IFDs contain a further pointer to other IFDs at the same level, or subIFDs. This makes a simple tree made of IFDs.