What did file output when previously given a CR2 file? What kind of
camera did it come from?

I'm having trouble finding a version of the magic which works; I
downloaded RAW samples from a Canon 10D and a 20D on rawsamples.ch,
and every version of file I test (including 4.26-1, which is the
version in Lenny) is reporting:

$ file RAW*
RAW_CANON_10D.CRW: data
RAW_CANON_20D.CR2: TIFF image data, little-endian

dcraw sees them properly:

$ dcraw -i RAW_CANON_10D.CRW RAW_CANON_20D.CR2
RAW_CANON_10D.CRW is a Canon EOS 10D image.
RAW_CANON_20D.CR2 is a Canon EOS 20D image.

Because the output from file is still technically correct, and I can't
find a working version, I'm changing the status to wishlist.

It's easy enough to patch, though; see the attached, which adds
support for both CR2 and CRW formats. I've tested it against a couple
of files from rawsamples.ch; please let me know if you run into any
problems. To the maintainer: if this needs to be in a different
format, please let me know, and I'll resubmit it.

Also, I've put "CR2" and "CIFF" in the description; these are somewhat
redundant, in that CIFF images are always version 1.2, and CR2 images
always 2.0; both of these matches could say "Canon raw image data,
version x.y". If anyone has suggestions, I'd be happy to implement
them.

With the patch:

$ file -m images RAW_CANON_10D.CRW RAW_CANON_20D.CR2
RAW_CANON_10D.CRW: Canon CIFF raw image data, version 1.2
RAW_CANON_20D.CR2: Canon CR2 raw image data, version 2.0

Adam Buchbinder
Author: Adam Buchbinder <[email protected]>
Description: Add Canon CRW and CR2 support. (Closes: #516054)

diff -Naurp file.orig/magic/Magdir/images file/magic/Magdir/images
--- file.orig/magic/Magdir/images	2009-02-20 10:43:12.000000000 -0500
+++ file/magic/Magdir/images	2009-02-20 14:15:11.000000000 -0500
@@ -61,6 +61,25 @@
 0	string		IIN1		NIFF image data
 !:mime	image/x-niff
 
+# Canon RAW version 1 (CRW) files are a type of Canon Image File Format
+# (CIFF) file. These are apparently all little-endian.
+# From: Adam Buchbinder <[email protected]>
+# URL: http://www.sno.phy.queensu.ca/~phil/exiftool/canon_raw.html
+0	string		II\x1a\0\0\0HEAPCCDR	Canon CIFF raw image data
+!:mime	image/x-canon-crw
+>16	leshort		x	\b, version %d.
+>14	leshort		x	\b%d
+
+# Canon RAW version 2 (CR2) files are a kind of TIFF with an extra magic
+# number. Put this above the TIFF test to make sure we detect them.
+# These are apparently all little-endian.
+# From: Adam Buchbinder <[email protected]>
+# URL: http://libopenraw.freedesktop.org/wiki/Canon_CR2
+0	string		II\x2a\0\x10\0\0\0CR	Canon CR2 raw image data
+!:mime	image/x-canon-cr2
+>10	byte		x	\b, version %d.
+>11	byte		x	\b%d
+
 # Tag Image File Format, from Daniel Quinlan ([email protected])
 # The second word of TIFF files is the TIFF version number, 42, which has
 # never changed.  The TIFF specification recommends testing for it.

Reply via email to