How can I convert GIFs to PNGs using Java?

John Zukowski

The Image I/O libraries added to Java 1.4 perform this for you:

  File inputFile = new File(filename);
  BufferedImage input = ImageIO.read(inputFile);
  File outputFile = new File(outfilename);
  ImageIO.write(input, "PNG", outputFile);
To get a list of available format one can read, use ImageIO.getReaderFormatNames(). (gif, jpg, png)

To get the list of available writable formats, use getWriterFormatNames() (jpg, png).

About | Sitemap | Contact