[OpenJDK 2D-Dev] Review Request for JDK-8152672 : Exception while getting second image properties for JPEG with embedded thumbnail
Brian Burkhalter
brian.burkhalter at oracle.com
Mon Jun 27 19:10:37 UTC 2016
The procedure for this is straightforward:
Inside the APP1 Exif marker segment locate the 8-byte TIFF header.
From the last four bytes of the TIFF header obtain the offset to the 0th Image File Descriptor (IFD).
Skip all the entries in the 0th IFD.
Obtain from the last four bytes of the 0th IFD the offset to the 1st IFD.
If the offset to the 1st IFD is zero, there is no thumbnail; otherwise seek to the offset of the 1st IFD.
Within the 1st IFD locate and obtain the values of the two entries with tags JPEGInterchangeFormat and JPEGInterchangeFormatLength. These provide respectively the offset to the SOI marker segment of the Exif thumbnail and the length of the Exif thumbnail data. If both of these entries are missing, then the file is aberrant and no thumbnail can be read. If only the JPEGInterchangeFormat entry is present, the thumbnail is likely still readable assuming it has the proper JPEG structure including a terminating EOI marker segment.
Seek to the value of the JPEGInterchangeFormat entry and decode the thumbnail. (It might not be a bad safeguard if possible to check that the two bytes at offset JPEGInterchangeFormat + JPEGInterchangeFormatLength - 2 are actually an EOI marker.)
It might not be a bad idea to add the above as a comment in the issue to be filed.
Brian
On Jun 25, 2016, at 9:57 AM, Philip Race <philip.race at oracle.com> wrote:
> - A follow-on bug should be filed that we do not locate thumbnails
> inside EXIF APP1 markers. We do not need to parse everything inside
> the APP1 marker to do this so it should be a moderate but not
> massive amount of work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20160627/80333122/attachment.html>
More information about the 2d-dev
mailing list