-
Bug
-
Resolution: Unresolved
-
P4
-
7, 8, 9
-
None
-
generic
-
generic
From email :
When we write a JFXX APP0 marker in JFIFMarkerSegment.java, we write out the length as:
LENGTH_SIZE + DATA_SIZE + thumb.getLength()
LENGTH_SIZE is 2 which accounts for the APP0 size field so we are good there.
DATA_SIZE is 6 which accounts for the "JFXX\0" and the 0x13 marker that defines this as an RGB thumbnail (both of which are written out by the code that computed the size above).
thumb.getLength() is (w * h * 3) which accounts for the pixels in the thumbnail.
But, nobody accounts for the 2 bytes for the w,h of the thumbnail, so the length field is written out 2 bytes short of the correct total. The "thumb" object is responsible for writing out that w,h so it should probably include them in its return value for its length I imagin, but the length only accounts for the RGB triples in the actual pixels.
There are other Thumbnail classes which I believe also omit the 2 bytes for the w,h from their getLength() field (the w,h are written by
super.write() in all cases so they are computing the bytes that they themselves write and ignoring what their superclass writes).
-----------------------------------------------------------------------------------------------------
With the attached image run ImageReader.readAll() and observe whether there are gaps while skipping imageindex 0 in JPEGImageReader.skipImage(). test/javax/imageio/plugins/jpge/ReadAllThumbnailsTest.java can also be used to observe this.
When we write a JFXX APP0 marker in JFIFMarkerSegment.java, we write out the length as:
LENGTH_SIZE + DATA_SIZE + thumb.getLength()
LENGTH_SIZE is 2 which accounts for the APP0 size field so we are good there.
DATA_SIZE is 6 which accounts for the "JFXX\0" and the 0x13 marker that defines this as an RGB thumbnail (both of which are written out by the code that computed the size above).
thumb.getLength() is (w * h * 3) which accounts for the pixels in the thumbnail.
But, nobody accounts for the 2 bytes for the w,h of the thumbnail, so the length field is written out 2 bytes short of the correct total. The "thumb" object is responsible for writing out that w,h so it should probably include them in its return value for its length I imagin, but the length only accounts for the RGB triples in the actual pixels.
There are other Thumbnail classes which I believe also omit the 2 bytes for the w,h from their getLength() field (the w,h are written by
super.write() in all cases so they are computing the bytes that they themselves write and ignoring what their superclass writes).
-----------------------------------------------------------------------------------------------------
With the attached image run ImageReader.readAll() and observe whether there are gaps while skipping imageindex 0 in JPEGImageReader.skipImage(). test/javax/imageio/plugins/jpge/ReadAllThumbnailsTest.java can also be used to observe this.
- relates to
-
JDK-8160943 skipImage() in JPEGImageReader class throws IIOException if we have gaps between markers in Jpeg image.
-
- Resolved
-
-
JDK-8152672 IIOException while getting second image properties for JPEG
-
- Resolved
-