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"); } } }
|