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

Some PNGs fail to load with ImageIO

XMLWordPrintable

    • b77
    • x86
    • windows_2000, windows_xp

        Name: rmT116609 Date: 09/07/2004


        FULL PRODUCT VERSION :
        java version "1.4.2_05"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
        Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

        java version "1.5.0-rc"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
        Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 2000 [Version 5.00.2195]

        A DESCRIPTION OF THE PROBLEM :
        An Exception occurs when using ImageIO to load some PNGs. Seems much more common with greyscale PNGs - I have a lot and it happens on about 5-10%. From multiple sources too (downloaded from internet). I haven't been able to create problem input files locally, however.

        Looks identical to bug-id 4463483. The line numbers are different, but looks otherwise identical.

        Every other image viewer I have can view the same files without any problem.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        This is all that's required:
        ImageIO.read(file);

        Where "file" is a path to a PNG file.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
          To get a java.awt.Image object
        ACTUAL -
        An exception is thrown


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        java.lang.IllegalArgumentException: LUT has improper length!
        at javax.imageio.ImageTypeSpecifier$Indexed.<init>(ImageTypeSpecifier.java:866)
        at javax.imageio.ImageTypeSpecifier.createIndexed(ImageTypeSpecifier.java:955)
        at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(PNGImageReader.java:1463)
        at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1348)
        at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1530)
        at javax.imageio.ImageIO.read(ImageIO.java:1400)
        at javax.imageio.ImageIO.read(ImageIO.java:1286)
        at slides.test.main(test.java:11)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package slides;

        import java.awt.Image;
        import java.io.File;
        import javax.imageio.ImageIO;

        public class test {
            public static void main(String[] args) {
                File file = new File(args[0]);
                try {
                    Image img = ImageIO.read(file);
                } catch (Exception E) {
                    E.printStackTrace();
                }
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Re-saving problem input images in an image editor works - the file then loads/displays properly via ImageIO. However, this isn't possible for remote images, as well as being tedious for the end-user.
        (Incident Review ID: 301679)
        ======================================================================

              bae Andrew Brygin
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: