problems in exporting CR2 to tif

Issue #332 closed
Alberto Ferrante created an issue

When exporting to tiff (16 bit) CR2 files from the Canon 5D Mk III and MkIV, multi-layer tif files are created. The tiff files also have some wrong tags. Imagemagick magick prints the following error:

magick: Sanity check on directory count failed, zero tag directories not supported. `TIFFFetchDirectory' @ error/tiff.c/TIFFErrors/592.
magick: Failed to read directory at offset 74252. `TIFFReadDirectory' @ error/tiff.c/TIFFErrors/592.

GIMP is able to open these files, but it shows 4 layers and while opening the image it shows the following errors:

Couldn't read page 2 of 4. Image might be corrupt.

TIFF directory is missing required "ImageLength" field

Couldn't read page 4 of 4. Image might be corrupt.

Jpegs export are exported just fine.

Please notice, this happens with CR2 files obtained with newer firwmare versions and not with older firmware releases (e.g., on the 5d MkIII it happens with CR2 files obtained with firmware 1.3.5, not with files obtained with firmware 1.3.3).

I’m currently using ART commit 6541e9cb89cde300ac977ecc44685413e3368c93 built from sources on Fedora Linux 40.

I have noticed the same behavior on rawtherapee some time ago, but never reported as I was unable to investigate the issue further. I have just checked and the issue is still there also in rawtherapee.

Comments (11)

  1. agriggio repo owner
    • changed status to open

    What metadata export mode are you using? Are you trying to preserve all tags (ie "copy unchanged"?) if so, thats probably the culprit (and it should not be used in general). If that's not the problem, please attach a raw and arp sidecar to reproduce,thanks!

  2. Alberto Ferrante reporter

    Thanks, I somehow overlooked that setting: it works fine with “strip all metadata”, it doesn’t with “copy unchanged” and “apply modifications”.

  3. agriggio repo owner

    Thanks for the files. However, I’m unable to reproduce here. What exiv2 version are you using?

    Regardless, it seems you are including a bunch of “unsafe” tags on export. My guess is that some of them are confusing the programs trying to open your tiff. Try unchecking the boxes related to the “Image”, “Image2”, and “Image3” groups. If that still doesn’t help, you can try also selectively removing some of the tags in the “Canon*” groups, until you identify which is the problematic one.

    HTH

  4. agriggio repo owner

    Update: unchecking the tags in the “Image”, “Image2” and “Image3” groups indeed solves the problem.

  5. Alberto Ferrante reporter

    Thanks a lot! To be honest, I never paid attention to tags in ART, leaving the default settings. I confirm that removing the “Image*” tags solves the problem.

  6. agriggio repo owner

    Great that it is sorted out. However, note that these are not the default settings. By default ART exports only the tags in the "Basic" group, exactly to avoid such kind of problems.

  7. Log in to comment