Amy Pearson Amy is the product lead for JDeli with expertise in image code, Java, web development, and cloud computing. She focuses on JDeli and has also contributed to JPedal, cloud services, and support. Outside work, she enjoys gaming, F1, and music.

How to write TIFF images in Java (Tutorial)

4 min read

TIFF icon

how to write tiff image (tiff icon)

TL;DR:

Java’s ImageIO has partial TIFF support, but it regressed between Java 8 and Java 11 and images that wrote correctly in Java 8 may fail in later versions. For reliable TIFF output, you need an external library. The two main options are Apache Imaging (free, open source) and JDeli (pure Java, commercial).

Does Java support TIFF natively?

Partially. ImageIO can write basic TIFF files, but support is incomplete and has known gaps. Java 11 removed TIFF functionality that existed in Java 8, so code that worked before may silently produce incorrect output or throw an exception on newer runtimes:

// This may return false or produce a broken file depending on
// your Java version and the image type
File file = new File("/path/to/output.tif");
boolean result = ImageIO.write(bufferedImage, "TIFF", file);
// result = false on some Java 11+ configurations

If you need reliable, version-independent TIFF output, use an external library.

Which Java TIFF library should you use?

ImageIO (native)Apache ImagingJDeli
Pure Java (no native binaries)
Works as ImageIO plugin
Direct API
Full TIFF spec coverage✗ (partial)✗ (partial)✗ (partial)
Consistent across Java 8 / 11+✗ (regression)
Encoder options (compression, colour)LimitedLimited
Supports other formats (AVIF, HEIC, WebP…)
CostFreeFreeCommercial
SupportCommunityApache / communityIncluded

Apache Imaging is a reasonable starting point if you have straightforward TIFF requirements and are not concerned about the Java version regression. JDeli is the better choice for production use, legacy code bases, server environments, or if you need consistent output across Java versions and broader format support.

Option 1: Write TIFF with native ImageIO

If you are still on Java 8 or your TIFF requirements are simple, native ImageIO may be sufficient:

File file = new File("/path/to/output.tif");
boolean written = ImageIO.write(bufferedImage, "TIFF", file);
if (!written) {
    // No suitable ImageIO writer found — check Java version and image type
    throw new IOException("Failed to write TIFF: no suitable writer found");
}

Check the return value. ImageIO.write() returns false rather than throwing when it cannot write, so failures are easy to miss.

Option 2: Add full TIFF support to ImageIO (no code changes)

JDeli registers itself as an ImageIO plugin. Once it is on the classpath your existing ImageIO.write() calls use JDeli automatically, with no code changes required.

Maven

<dependency>
    <groupId>com.idrsolutions</groupId>
    <artifactId>jdeli</artifactId>
    <version>[JDELI_VERSION]</version>
</dependency>

Gradle

implementation 'com.idrsolutions:jdeli:[JDELI_VERSION]'

Alternatively, download the trial jar and add it to your classpath manually. See the ImageIO configuration guide for setup details.

Once JDeli is on the classpath:

// Your existing ImageIO code — no changes needed
File file = new File("/path/to/output.tif");
ImageIO.write(bufferedImage, "TIFF", file);

Option 3: Write TIFF directly with the JDeli API

The JDeli API gives you more control and does not depend on ImageIO’s plugin registration order.

  1. Add JDeli to your class or module path. (download the trial jar)
  2. Create a File or OutputStream for the output.
  3. Call JDeli.write() with your image, format, and output target.
// String format
JDeli.write(bufferedImage, "tiff", new File("/path/to/output.tif"));
// Type-safe enum (preferred)
JDeli.write(bufferedImage, OutputFormat.TIFF, new File("/path/to/output.tif"));

Controlling output with TiffEncoderOptions

For production use, pass a TiffEncoderOptions object to control compression and other output settings:

TiffEncoderOptions options = new TiffEncoderOptions();
JDeli.write(bufferedImage, options, new File("/path/to/output.tif"));

See the JDeli TIFF documentation for the full list of encoder options.

Frequently asked questions

Why does my TIFF code work in Java 8 but fail in Java 11?

Java 11 removed some TIFF codec functionality that was present in Java 8. The result is that ImageIO.write() may return false or produce incorrect output for certain image types. Using an external library such as JDeli or Apache Imaging avoids this problem entirely.

What is JDeli?

JDeli is a pure Java image library from IDR Solutions. It has no native binaries, supports reading, writing, and converting TIFF and other formats (AVIF, HEIC, WebP, and more), and works as both an ImageIO plugin and a standalone API.

Is Apache Imaging a good alternative?

Apache Imaging is a reasonable free option for basic TIFF writing. It is pure Java and actively maintained. Its TIFF support is more limited than JDeli’s and it does not function as an ImageIO plugin.

Can I read TIFF files in Java with JDeli?

Yes. See our companion article: how to read TIFF files in Java.

Is JDeli pure Java?

Yes. JDeli has no native binaries and makes no calls to platform-specific libraries. This makes it straightforward to deploy on any Java-supported platform, including containerised and server environments.

Other useful TIFF resources

As experienced Java developers, we help you work with images in Java and bring over a decade of hands-on experience with many image file formats.



Are you a Java Developer working with Image files?

Amy Pearson Amy is the product lead for JDeli with expertise in image code, Java, web development, and cloud computing. She focuses on JDeli and has also contributed to JPedal, cloud services, and support. Outside work, she enjoys gaming, F1, and music.

12 Replies to “How to write TIFF images in Java (Tutorial)”

    1. we are on the process of writing tiff decoder (tiff encoder is already available)
      once it is finished we will post examples of how to do conversions on our website.

      i recommend keep an eye on JDeli release notes (there are plenty of features on the way)

  1. Thanks Mark. I tried it out. I am using the com.twelvemonkeys.imageio:imageio-tiff:3.1.1 implementation for ImageIO. Some images are turning out black after the conversion.

      1. Sorry, I do not have much experience with image transformations. So, I am not sure if it caused by reading the image using ImageIO or using jDeli for transforming it.

      2. Added the code below. I have tried this out with 4 Tiff images. Just one image is turning out black. Others are getting converted fine.

        public void transform(InputStream in, OutputStream out, Map params) throws IOException {
        try {
        BufferedImage image = ImageIO.read(in);
        JpegEncoder encoder = new JpegEncoder();
        encoder.write(image,out);

        } catch (Exception e){
        e.printStackTrace();
        }
        }

Comments are closed.