Search This Blog

Java JAI ImageIO: read tiff file and save it to png

package examples;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class ImageUtil {
 
 public static void main(String[] args) throws Throwable {

  File inputFile = new File("/tmp/1.tif");
  File outputFile = new File("/tmp/1.png");
  BufferedImage image = ImageIO.read(inputFile);
  ImageIO.write(image, "png", outputFile);

 }

}

Note:

you need to make sure jai_imageio.jar is in the classpath. To install jai imageio on Mac OS X see here.

No comments:

Post a Comment