How do I convert a TIF to PNG in Java?

James McMahon picture James McMahon · Feb 18, 2010 · Viewed 27.9k times · Source

Under Java what is the best way to go about converting an TIF file to a PNG?

Simplicity is preferable, but if the simplest way is to use a third party library then I would consider that solution.

Answer

Jonathan Feinberg picture Jonathan Feinberg · Feb 18, 2010

First, install JAI. Then install JAI/ImageIO. Then do

public static void main(final String[] args) throws Exception
{
    final BufferedImage tif = ImageIO.read(new File("test.tif"));
    ImageIO.write(tif, "png", new File("test.png"));
}