RFR: 8160327: Support for thumbnails present in APP1 marker for JPEG [v2]
Jeremy
duke at openjdk.org
Mon Feb 24 06:45:57 UTC 2025
On Fri, 14 Feb 2025 17:34:05 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/ExifMarkerSegment.java line 165:
>>
>>> 163: ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
>>> 164: if (input.readUnsignedShort() != TIFF_MAGIC) {
>>> 165: throw new IllegalArgumentException("Bad magic number");
>>
>> Where does this exception end up ? I would have supposed that if there's an Exif segment we don't like it would be best to just act like the segment isn't there.
>
> I concur.
When you first asked: this exception would be thrown all the way up to the JPEGImageReader's caller. (That is: calling `myJPEGReader.getNumThumbnails` would throw this IAE.)
As of this writing: now this exception is ignored. It is consumed in this code in JPEGMetaData:
case JPEG.APP1:
newGuy = new MarkerSegment(buffer);
newGuy.loadData(buffer);
if (newGuy.data.length > 5 &&
newGuy.data[0] == 'E' &&
newGuy.data[1] == 'x' &&
newGuy.data[2] == 'i' &&
newGuy.data[3] == 'f' &&
newGuy.data[4] == 0) {
try {
newGuy = new ExifMarkerSegment(newGuy);
} catch(Exception e) {
// This is intentionally empty.
// Now we fallback to keeping the generic MarkerSegment
}
}
break;
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22898#discussion_r1967100476
More information about the client-libs-dev
mailing list