From: Roberto C. <rob...@en...> - 2003-08-25 20:04:52
|
Hello, I read a message posted in this mailing list, in which a Canon user claims that files processed by libexif shrink. I notice the same behavior with the files produced by my camera (a Canon, but I think what I'm going to say is more general), so I investigated in order to understand what libexif leaves behind. Padding bytes, which are not reproduced by libexif, may be an explanation, but only a partial one. The real and most serious reason why a file shrinks is that maker note data that is referenced within MakerNote entry but is allocated outside is lost whenever libexif tries to write the file! Think about the format of an IFD: each entry whose data size is bigger than 4 bytes is listed indeed within the IFD, but its contents is stored outside! Several camera manifacturers organize the MakerNote entry like a IFD, sad but true. What currently happens is that, at least for some cameras, libexif silently corrupts MakerNote entry. This unfortunately isn't libexif's fault (unfortunately, because eventual libexif's faults can be corrected!), I see it as a flaw in exif's specs: since nobody else is supposed to know what the maker note means, it should have been enforced that its data do not spread beyond its "visible" borders. However, I think this can't be an excuse. Only two behaviors are acceptable to my eyes for files written by libexif: a) libexif drops the entire MakerNote entry and warns the user that it has done so; b) libexif successfully reproduces MakerNote entry, even without knowing what its contents means. I don't like the first, so I'm trying to come out with an idea to get the second. I already have something in mind. Suppose that libexif: -) builds a sort of map of the apparently unused regions of the exif section of the original file; -) keeps all those regions unchanged in the output file (for unchanged I mean same values at the same offsets). Shouldn't this work out? Of course it does not if a maker note references datas external to itself with relative offsets, but we must make some common-sense assumptions. In order to preserve maker notes that use relative offsets to external datas, we would need to make sure that the output-file offset of the maker note itself is the same of the input file, which I see it as a much harder constraint. What do you think about it? Does it make sense? I'm looking forward to hear your opinions about all that, mine are just a bunch of ideas from someone who is relatively new with exif information. Cheers, Roberto |