Hello,
I notice that files modified by libexif contain apparently random values
in the extra bytes of exif entries that are smaller than 4 bytes.
For instance, if an entry is composed of one component of type short,
libexif writes the value of the short into the first two bytes of the
entry data, while the last two are left undefined (memory is allocated
without being initialized).
I understand this probably doesn't violate exif's specs, however it
would make more sense to me if those useless bytes were set in a
predictable way (for instance now libexif, if run on two different
machines, is likely to produce slightly different output files).
The easiest solution is to fill them with zeroes, which is
straightforward to be implemented: it's sufficient to add a couple of
lines in fuction exif_data_save_data_entry(...). Attached you can find a
3-line patch for libexif/exif-data.c
An alternative solution that makes sense to me as well is to fill the
eventual extra bytes with the value they have in the input file
(provided that the entry was already present!). The purpose is that of
changing the input file as less as possible.
This solution would require a bit more hacking, since a 4-byte value
would have to be read and stored even for entries whose size is smaller.
I don't know whether this is worthwhile, probably not.
Do you have any experience about what cameras do with such extra bytes?
Mine (a Canon) always fills them with zeroes, if this were the most
typical case, I wouldn't hesitate to recommend the first solution (and
my patch).
Cheers,
Roberto |