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

Java unable to convert from gif to png format

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 7
    • 5.0, 5.0u12
    • client-libs
    • b14
    • x86, sparc
    • solaris_10, windows_xp
    • Verified

    Backports

      Description

        The issue appears to be the conversion routine in Java doesn't handle well transparent gifs, what the attached file is.

        The test case outputs successful, but the outputted .png file can't be opened.
        I have tested this with 1.4.2 and 1.5.0. Are transparent gifs supported?
        I have tested another conversion tool and it was successful in converting this file.

        import java.awt.image.RenderedImage;
        import java.io.File;
        import javax.imageio.ImageIO;


          //==========================================================
          // M A I N
          //==========================================================
        public class Image {
          public static void main(String[] args) {
            String inputFile = "sample.gif";
            String outputFile = "sample.png";
            try {
              RenderedImage image = ImageIO.read(new File(inputFile));
              if (ImageIO.write(image,"png", new File(outputFile)))
              {
                System.out.println("Image converted successfully");
              }
            }
            catch (Exception ex) {
                System.out.println("EXCEPTION OCCURED");
            }
          }
        }

        Attachments

          Issue Links

            Activity

              People

                bae Andrew Brygin
                hnassiry Haroon Nassiry (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: