CR2 files are generated by Canon cameras, starting the 20D, 350D/Digital Rebel Xt and 1D. They supersede the older Canon CRW.

MIME type



Canon CR2 files are TIFF files. All is organised in a TIFF / IFD file.

On of the differenciation with the CR2 files is that they have a header before the IFD0. This does not violate the TIFF spec.

offset length description
0 8 TIFF header
8 2 litteral ‘CR’
10 1 major version (2)
11 1 minor version (0)
12 4 (long) for the offset of the IFD3 that contain the RAW data. (in the TIFF byte order)

Exif is attached to the ExifIFD of IFD0. The CFA data is in IFD3.


Canon CR2 files use the old original Lossless JPEG standard for the RAW data. The same used by Adobe DNG.

Source: (Dead link)

The width dimension specified in the JPEG stream is actually half the reality because it takes into account 2 channels per sample (the dimension of the CFA pattern).

350D, 5D and 30D files have a different layout. IFD3 (where the CFA is located) has the tag 0xc640 that contains 3 SHORT. 1, x, y. x is the number of column of the first “slice” of the image, y is for the second “slice”.** I don’t know what the 1 mean.**

The slicing means that the output scanlines have to be reorganised as they are shorter to have a top -> bottom then left -> right, a bit like columns of text. (TODO: do a nice diagram)

Modified files

Apparently Canon’s proprietary software modifies the RAW file. Other proprietary software seems to choke on said modified files ( - via the Internet Archive).

ExifTool has some info:


Lens info

Older Canon cameras do not have a reliable LensType field. For example my 20D does not and put 0xffff, while some later Rebel model does.

So there are two ways: if you have a consistent CameraSettings.LensType, use it.

If you don’t (0xffff for example) you have other lens info that should allow to reduce the list to a bunch and require some user selection for the few last cases. For that there are a few fields in the makernotes:

First the FocalLength.FocalType to see if it is a zoom or a prime.

Second CameraSettings.LongFocal and ShortFocal, and MaxAperture + MinAperture.