Skip to content

Canon digital camera RAW file (.cr2)

.cr2 file signature | image/x-canon-cr2

Canon Digital Camera RAW (CR2) is a raw image file format developed by Canon for its digital cameras and based on the TIFF standard. It is used to store unprocessed sensor data for photography workflows, including professional editing, color correction, and long-term image archiving in software such as Canon utilities and third-party raw processors. The format is generally considered safe, though like other image files it should be opened with updated software.

Safe

Magic Bytes

Offset 0
4D 4D 00 2A

Sources: Apache Tika

All Known Signatures

6 signature variants are documented for .cr2 files across multiple sources.

Hex Signature Offset Sources
4D 4D 00 2A 0 Apache Tika
49 49 2A 00 0 Apache Tika
4D 4D 00 2B 0 Apache Tika
49 49 2A 00 10 00 00 00 0 Wikipedia
43 52 0 Wikipedia
49 49 2A 00 10 00 00 00 43 52 0 Gary Kessler

Extension

.cr2

MIME Type

image/x-canon-cr2

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .cr2 files in Python

Python
def is_cr2(file_path: str) -> bool:
    """Check if file is a valid CR2 by magic bytes."""
    signature = bytes([0x4D, 0x4D, 0x00, 0x2A])
    with open(file_path, "rb") as f:
        return f.read(4) == signature

How to validate .cr2 files in Node.js

Node.js
function isCR2(buffer: Buffer): boolean {
  const signature = Buffer.from([0x4D, 0x4D, 0x00, 0x2A]);
  return buffer.subarray(0, 4).equals(signature);
}

How to validate .cr2 files in Go

Go
func IsCR2(data []byte) bool {
    signature := []byte{0x4D, 0x4D, 0x00, 0x2A}
    if len(data) < 4 {
        return false
    }
    return bytes.Equal(data[:4], signature)
}

API Endpoint

GET /api/v1/cr2
curl https://filesignature.org/api/v1/cr2

See the full API documentation for all endpoints and parameters.

Related Formats

Frequently Asked Questions

What is a .cr2 file?

A .cr2 file is a Canon digital camera RAW file file. Canon Digital Camera RAW (CR2) is a raw image file format developed by Canon for its digital cameras and based on the TIFF standard. It is used to store unprocessed sensor data for photography workflows, including professional editing, color correction, and long-term image archiving in software such as Canon utilities and third-party raw processors. The format is generally considered safe, though like other image files it should be opened with updated software.

What are the magic bytes for .cr2 files?

The magic bytes for Canon digital camera RAW file files are 4D 4D 00 2A at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .cr2 file?

To validate a .cr2 file, read the first bytes of the file and compare them against the known magic bytes (4D 4D 00 2A) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .cr2 files?

The primary MIME type for .cr2 files is image/x-canon-cr2.

Is it safe to open .cr2 files?

Canon digital camera RAW file (.cr2) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.