The API documentation for reader.getWidth(imgIndex), reader.getHeight(imgIndex), reader.getAspectRatio(imgIndex) claims that the above methods would throw an IndexOutOfBoundsException when the given image index is out of range. But this is not working for PNG ImageReader. PNG ImageReader returns the same width, height and aspect ratio regardless of what imageIndex is passed and the ImageIndex is not at all getting validated. This works fine for other readers such as GIF, JPEG and BMP. This gives an impression to the user that the image index specified by him exists in the input source even if it is out of range. This must be fixed and the exception must be thrown appropriately.
This is noticed since JDK1.4+ on Win32 as well as Solaris platforms.
I have attached a sample code. Execute the sample code as follows.
java ImageReaderTest <img file>
For Ex: java ImageReaderTest cup.png
If you don't see any exception, the bug is reproduced.