RFR: 8160327: Support for thumbnails present in APP1 marker for JPEG [v2]

Brian Burkhalter bpb at openjdk.org
Tue Feb 18 23:07:59 UTC 2025


On Thu, 2 Jan 2025 06:49:19 GMT, Jeremy <duke at openjdk.org> wrote:

>> This adds support for parsing thumbnails in an APP1 Exif marker.
>> 
>> This builds on an unfinished proposal by Brian Burkhalter (around 2016). In that previous work the only additional meta info he parsed was the image creation time; this PR similarly includes the same property. (I can't speak to why he included that property, but it looks like he has a lot of experience with ImageIO so I trust his judgment.)
>> 
>> The test addresses the original images attached to the ticket plus a few extra images I found on my computer that include unusual properties. (Possibly those images are malformed, but if they exist in the wild and other platforms support them then I'd prefer to support them too.)
>
> Jeremy has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8160327: fixing typo so `thumbnailPos` can be zero
>   
>   The `thumbnailLength` cannot be zero, but the position can be.

> I initially didn't support _both_ JFIF and EXIF thumbnails because I read that the two were technically incompatible.

You are correct, as is the superuser answer (thanks for the link). If the specifications are followed to the letter, then they are incompatible.

> [...] it sounds like you're confident there's enough real-world use cases to justify supporting both, right?

I don't have enough information to justify that. I do know from experience in other formats, however, that one sometimes needs to support cases which are actually non-compliant. Otherwise people will complain with something like "Acme Image Library can read the image but Java cannot." Here I just think we need to do something that makes sense, go with it, and document it.

There is also a minor backward compatibility issue. I think that without this change, the JPEG reader will show one thumbnail for `jfif-jfif-and-exif-thumbnail-sharpshot-iphone.jpg`, which is the JFIF thumbnail, but if the change is applied as is, there will still be just one thumbnail, but now it will be the one from the Exif 1st IFD. As noted above, those two thumbails for this image are not the same, as weird as that is.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22898#issuecomment-2667122865


More information about the client-libs-dev mailing list