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

JPGWriter.getNumThumbnailsSupported does not return -1 when passing null values

XMLWordPrintable

    • b08
    • generic
    • generic

      This is regarding the getNumThumbnailsSupported() method available in ImageWriter. The API doc for this method claims that a particular writer implementation will return -1 if sufficient information is not available. I am passing null values for all the parameters in this method to JPG writer and it still returns Integer.MAX_VALUE.

      When I looked into the source code, it invokes jfifOK() method and passes all the parameters to that method. That method in turn calls isJFIFCompliant() method available in the JPEG class if the image type specifier given is not null. Else it proceeds to check the metadata for the existance of
      JFIFMarkerSegment if metadata passed is not null. If both the metadata and the image type are null, it returns Integer.MAX_VALUE. I feel this is slightly misleading. As per the document, it is supposed to return only -1 when there are no sufficient information. So in this case, since all the parameters are null, it has got nothing to check actually and hence it is supposed to notify the user that it does not have sufficent information to look through, by returning a '-1' value.

      Also I noticed that the stream metadata value passed to the above method is not used anywhere inside the method. It can be removed if that is not really required.

      For all other formats such as PNG, BMP, WBMP the above method returns 0. This is reproducible on all the platforms right from JDK1.4.

      I have attached a sample code. Execute the sample code and see the value printed on the console. If it is Integer.MAX_VALUE then the bug is reproduced.

            pnarayanan Prahalad Kumar Narayanan (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: