Site iconJava PDF Blog

How to write TIFF images in Java

TIFF icon

In this article, I will walk you through how to write out images as TIFF images in Java. We also have a related article covering how to read TIFF files in Java.

ImageIO is able to write images as TIFF files, but it offers the developer very little control over the process or output. We added TIFF support to our JDeli Image library so we could get high-quality TIFF output. In this article, I show you how to use either JDeli or ImageIO and cover the benefits of JDeli.

How to write an image as a TIFF file in ImageIO

  1. Create a File (or OutputStream) object for the TIFF output.
    File file = new File("/path/to/outputFile.tif"));
  2. Pass image, TIFF type, and File (or OutputStream) object into write method
    ImageIO.write(bufferedImage, "TIFF", file);

How to write an image as a TIFF file with JDeli

  1. Add JDeli to your class or module path. (download link to the trial jar).
  2. Create a File (or OutputStream) object
    File file = new File("/path/to/outputFile.tif"));
  3. Pass image, TIFF type, and File (or OutputStream) object into write method
    JDeli.write(bufferedImage, "tiff", file);

In JDeli you can also use a typesafe version

JDeli.write(bufferedImage, OutputFormat.TIFF, file);

or pass in a TiffEncoderOptions object for more control over TIFF image output, such as level of Compression.

TiffEncoderOptions options = new TiffEncoderOptions();
JDeli.write(bufferedImage, options, file);