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.r...@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.

Reply via email to