Re: PNG Loves EXIF
Dustin Oprea <[email protected]> Mon, 18 Jun 2018 00:42:06 -0400
| Newsgroups | gmane.comp.graphics.png.devel |
|---|---|
| Message-ID | <CAOr1xOGGZCrGrsVdBvRvNqa4m605i28PxvcLu_M4a-sU0uzYfA@mail.gmail.com> |
When my parser was having difficulty parsing your images, I manually inspected the binary structure. This is the breakdown of the EXIF information from that file: 0: 4d4d 002a 0000 0008 8: 0002 10: 0112 0003 0000 0001 0005 0000 22: 8769 0004 0000 0001 0000 0026 34: 0000 0000 38: 0001 40: a405 0003 0000 0001 012c 0000 The tag at offset 22 (dec) points to the EXIF IFD at offset 0x26 (38 dec). Notice that whereas there's a uint32(0) offset at the end of IFD0 (at 34 dec), there's no offset at all at the end of the EXIF IFD (at 38 dec, where the offset should have been found at 52 dec). The 0xa405 tag (starting at offset 40 dec) correlates to 41989 (dec) in your dump, so you're definitely seeing the malformed EXIF IFD, regardless. Those tools are forgiving the missing offset. This is usually zero in all but IFD0, but they're all still supposed to have the required IFD structure. This might seem like an innocent and forgivable issue, but, per the EXIF/TIFF specs, tools are supposed to parse those four bytes and interpret them as an offset. If they're undefined data, that's a new and different problem that will have undefined results. Exercpt from the 2016 PNG document cited as standard and reference at the bottom of the PNG-EXIF draft (the 2012 document uses identical language): ( http://www.simplesystems.org/png-group/proposals/eXIf/png-proposed-eXIf-chunk-2017-06-15.html ) (http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf) *The IFD used in this standard consists of a 2-byte count (number of fields), 12-byte field* *Interoperability arrays, and 4-byte offset to the next IFD, in conformance with TIFF Rev. 6.0.Each of* *the 12-byte field Interoperability consists of the following four elements respectively.* I encountered this either because I ran out of data in the chunk (expected to find four more bytes and didn't) or because I tried to resolve that offset and couldn't. Either way, the EXIF is corrupt/invalid and processing should be skipped (in my opinion). Since this PNG file was hacked together for the purpose of implementation (because no other version previously existed in the world) and the *libpng* implementation doesn't actually parse the EXIF data, it's an issue that was easy to overlook, but is there some reason we can't just fix the test data to have the same minimum structure as any other image? I would argue that having EXIF data that doesn't actually resemble the average image also just isn't good test data Thanks, Cosmin. Dustin On Sun, Jun 17, 2018 at 11:58 PM, Cosmin Truta <[email protected]> wrote: > On Sat, 16 Jun 2018 at 10:46, Dustin Oprea wrote: > > Thanks, Cosmin. I just did a new release. Try it now. > > Looks good! > > > I did observe one thing with the libpng implementation: Initially, I > used the test image used for the EXIF unit-tests from libpng in my own > unit-tests, but I ended-up not being able to. An EXIF IFD block ends in a > uint32, which is a pointer to another IFD. This is usually only non-zero > for IFD0, where it points to IFD1. Either way, this is required. It is > missing from the IFD in the test PNG. I'm guessing that the libpng > implementation has a bug where it doesn't actually read/write this integer, > or is, at least, not checking for this in the unit-tests. > > I tried my own Python implementation, pngexifinfo, and that one can > see the IFDs. It displays the following: > > $ pngexifinfo.py pngtest.png > EXIF (endian=MM) > Orientation (274) (type=3:short) (count=1) : 0x00050000 > EXIF IFD (34665) (type=4:long) (count=1) : 0x00000026 > [Unknown] (41989) (type=3:short) (count=1) : 0x012c0000 > > Then I tried exiftool, and that one, too, works fine. > > I think the EXIF field in pngtest.png is correct, and you are probably > having a bug in your implementation. > > Sincerely, > Cosmin > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > png-mng-implement mailing list > png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/png-mng-implement > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ png-mng-implement mailing list png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/png-mng-implement