Skip to content

Canon digital camera RAW file (.cr2)

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

Canon RAW Format Version 2[12]Canon's RAW format is based on TIFF.[13]

Safe

Magic Bytes

Offset 0
49 49 2A 00 10 00 00 00 43 52

Sources: Wikipedia, Gary Kessler

All Known Signatures

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

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

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([0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52])
    with open(file_path, "rb") as f:
        return f.read(10) == signature

How to validate .cr2 files in Node.js

Node.js
function isCR2(buffer: Buffer): boolean {
  const signature = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52]);
  return buffer.subarray(0, 10).equals(signature);
}

How to validate .cr2 files in Go

Go
func IsCR2(data []byte) bool {
    signature := []byte{0x49, 0x49, 0x2A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x43, 0x52}
    if len(data) < 10 {
        return false
    }
    return bytes.Equal(data[:10], signature)
}

API Endpoint

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .cr2 file?

A .cr2 file is a Canon digital camera RAW file file. Canon RAW Format Version 2[12]Canon's RAW format is based on TIFF.[13]

What are the magic bytes for .cr2 files?

The magic bytes for Canon digital camera RAW file files are 49 49 2A 00 10 00 00 00 43 52 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 (49 49 2A 00 10 00 00 00 43 52) 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.