Canon CR3 HEIC preview extraction?

Started by sloan.d, April 04, 2021, 12:40:48 PM

Previous topic - Next topic

sloan.d

Just wondering if exiftool supports extraction of HEIC encoded previews from a CR3 CRAW format (EOS R5)?

- David

Phil Harvey

ExifTool extracts these previews from an EOS R5 CR3 file:

> exiftool CanonEOS_R5.cr3 -preview:all -a
Thumbnail Image                 : (Binary data 20384 bytes, use -b option to extract)
Jpg From Raw                    : (Binary data 3494178 bytes, use -b option to extract)
Preview Image                   : (Binary data 378304 bytes, use -b option to extract)


They are all JPG format.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sloan.d

Thanks Phil for the quick reply. I suspect the preview is HEIC encoded since the R5 is set to capture both CR3 (HDR, CRAW) and HEIC (HDR). exiftool

exiftool CB7A1303.CR3 -PreviewImage -b
Warning: [minor] PreviewImage is not a valid JPEG image - CB7A1303.CR3

- David

Phil Harvey

Hi David,

This is different from my R5 CR3 sample that I have.  Could you send me a sample and I'll take a look?  (philharvey66 at gmail.com)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sloan.d

Hi Phil,

As requested, I sent you an email with a link to an example.

- David

Phil Harvey

Hi David,

I got it.  You're right, this isn't a JPEG preview.  In fact, it isn't any stand-alone image format that I recognize.

I'll look into this in more detail when I get a chance -- maybe there is a way for ExifTool to wrap this in a known container to make it useful.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sloan.d

Thanks Phil. I believe that the Preview is in HEIC format but perhaps missing a proper image header.

- David

sloan.d

Found this https://github.com/strukturag/libheif/issues/206 information reproduced below:


for HDR CR3 files, HEIF metadata are inside THMB and main CRAW boxes.
you can find Canon markers:

CISZ (likely Canon Image SiZe)
IMGD (likely IMaGe Data)
and usual HEIF infos: hvcC, colr, pixi

see https://github.com/lclevy/canon_cr3

I:\dev\canon_cr3>python parse_cr3.py -v 1 "d:\cr3_samples\1dx3\struktur 1D X Mark III HEIF samples\93FG5559.CR3"
filesize 0x17dbc58
00000:ftyp: major_brand=b'crx ', minor_version=1, [b'crx ', b'isom'] (0x18)
00018:moov: (0xacf0)
00020: uuid: b'85c0b687820f11e08111f4ce462b6a48' (0xa310)
00038: CNCV: b'CanonCR3_002/00.10.00/00.00.00' (0x26)
...
03758: THMB: version=1, width=320, height=214, jpeg_size=0x6bc0 (0x6bd8)
03770: b'CISZ' b'000000000000014000000140' (0x14)
03784: b'hvcC' b'0104080000009d20000000003cf000fcfefafa00000f03a0' (0xaf)
03833: colr: b'nclx' 9 10 9 80
03846: pixi: 3, 10 10 10
03856: b'IMGD' b'00006ac000006abc2601ac18c0f9558525640207952fbd1c' (0x6acc)
0a330: b'mvhd' b'00000000da72f103da72f103000000010000000100010000' (0x6c)
....
0a491: b'stsd' b'000000000000000100000170435241570000000000000001' (0x180)
00010: CRAW: (0x170)
width=5472, height=3648, bits=24
0005a: b'HEVC' b'000000010000001847524944000000000000000400000101' (0x10c)
0000c: b'GRID' b'00000000000000040000010115600e40' (0x18)
00024: b'CISZ' b'0000000000000ac000000740' (0x14)
00038: b'hvcC' b'0124080000009d200000000099f000fcfefafa00000f03a0' (0xb1)
000e9: colr: b'nclx' 9 10 9 80
000fc: pixi: 3, 10 10 10
00166: b'free' b'0000' (0xa)