Project

General

Profile

Size differences with CR2 writing

Added by Thomas Lotze over 9 years ago

Hi there,

I'm excited to see write support for Canon's CR2 format has been added to exiv2. Thanks!

However, having tried it out, I'm a bit unsure about the result. I've only adjusted the EXIF timestamp by some offset. On the one hand, the resulting image file seems to work just fine: it can still be loaded into applications, and the EXIF data as reported by exiv2 are still the same (up to some magic numbers) as those of the original file.

However, the size of the new file is quite a bit smaller than the original. For a 25 MB original CR2 file (from an EOS 5D Mark II), the difference is as much as about 400 kB. Is there some known explanation for such a difference? Can I be certain that all the difference is due to some kind of better compression of file layout by exiv2 than by the camera? Or is there a possibility that exiv2 loses data when writing the output CR2 file, even if it's data that exiv2 doesn't understand? Except for possible differences in compression, I'd expect the file size to remain the same when chaging an existing timestamp.

Thank you.
Thomas


Replies (8)

RE: Size differences with CR2 writing - Added by Andreas Huggel over 9 years ago

Hi Thomas,

Yes, in general the resulting image may become smaller when Exiv2 writes metadata to an image, most likely because it doesn't know the Makernote structure well enough. For example, if the Canon makernote contains a tag which is an offset to an IFD but Exiv2 isn't aware of that, then the resulting metadata will not contain the IFD pointed to by that offset. Technically, that's not an issue with CR2 support, it's an issue with Canon makernote support and I don't expect the image data to be affected by this.

On the other hand, just adjusting the EXIF timestamp shouldn't have that effect. In order to minimize the issue mentioned above, Exiv2 uses what I call a "non-intrusive" write-algorithm if possible: If all you do is overwrite an existing field without making it longer, then Exiv2 should do exactly that: just overwrite the corresponding bytes in the file rather than try to re-write the entire TIFF structure. That way, non-intrusive writing preserves the information in the file, whether or not Exiv2 understands it.

How did you change the timestamps in your file? Do you observe the problem if you use something like a simple

exiv2 -a1 image.cr2

or did you make the change with an application that uses the Exiv2 library?

Andreas

RE: Size differences with CR2 writing - Added by Thomas Lotze over 9 years ago

Hi Andreas,

in fact I did use the exiv2 executable:

exiv2 ad -a -00:03:10 image.cr2

For the record, I'm using exiv2-0.23.tar.gz (MD5: dab67c07bb63a4386d4ea607a8e06eaf) as downloaded from the project website, with ./configure output ending like this:

------------------------------------------------------------------
-- Exiv2 0.23 feature configuration summary
--
-- Build a shared library......... YES
-- Use symbol visibility support.. YES
-- PNG image support.............. YES
-- Native language support........ YES
-- Nikon lens database............ YES
-- XMP metadata support........... YES
------------------------------------------------------------------

Tell me if you need more details or one of my image files to reproduce.

Thank you.
Thomas

RE: Size differences with CR2 writing - Added by Andreas Huggel over 9 years ago

I can reproduce this with one of my CR2 images (have only tried one). It indeed uses the intrusive write strategy and I'll have to spend a bit more time to understand why... If you add -Qd to your statement, you can see what write strategy is used.

Andreas

RE: Size differences with CR2 writing - Added by Thomas Lotze over 9 years ago

Thank you. I'll then be holding my breath about adjusting timestamps of my images until you found out something. Let me know if I can help in any way.

Thomas

RE: Size differences with CR2 writing - Added by Andreas Huggel over 9 years ago

Created issue #831 for this, working on a fix.

-ahu.

RE: Size differences with CR2 writing - Added by Andreas Huggel over 9 years ago

Thomas, I checked-in a fix with r2766. Can you please try that to check if it also solves the problem with your CR2 files?
Thanks,
Andreas

RE: Size differences with CR2 writing - Added by Thomas Lotze over 9 years ago

Andreas,

I have just tried out your fix and it works fine on my images. Thank you very much indeed!

Thomas

RE: Size differences with CR2 writing - Added by Andreas Huggel over 9 years ago

Thanks for testing again and for reporting this issue. As it turned out, this is a bug introduced in version 0.20 which affects all TIFF-like images. I'm quite surprised it managed to hide for so long.

Andreas

    (1-8/8)