Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8162950

ImageIO is not calculating length of APP0/JFXX thumbnails properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7, 8, 9
    • client-libs
    • None

      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.

            jdv Jayathirth D V
            jdv Jayathirth D V
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: