Link
Skip to main content

Java TIFF Reader

The JDeli Java image library includes a TIFF Reader to read TIFF images into Java. The TIFF Decoder is written in 100% Java and provides TIFF support with no dependencies.

What is supported

The JDeli TIFF reader supports the following features:

Feature Supported
multi-image yes
Alpha channels Yes
resolution setting Yes
BufferedImage input Yes
Compression - DEFLATE Yes
Compression - LZW Yes
Compression - JPEG Yes
Metadata TIFF
Takes file input Yes
Takes InputStream input Yes
Takes byte[] input Yes
Pure Java implementation Yes

Quick start:

Add JDeli to your project via Maven or Gradle, or see using JDeli with Java modules.

JDeli can automatically detect the file type and will use the TIFF File Reader

BufferedImage image = JDeli.read(tiffImageFile);

or

TiffDecoder decoder = new TiffDecoder();
BufferedImage image = decoder.read(tiffData);

See the full Javadoc.

Performance comparisons:

These figures were generated using jmh (as documented on our blog) with a standard set of images (also documented). They should be easy to replicate if you wish to validate, the code is on GitHub.

The higher the number, the better.

Mode: Throughput Count: 25 Units: ops/s

Benchmark Score Error
Apache 85.484 ± 1.042
ICafe 53.449 ± 0.256
ImageIO/JAI 202.655 ± 10.778
ImageIO/TwelveMonkeys 136.411 ± 2.603
JDeli 95.312 ± 4.090

Tested on 2020 13inch M1 MacBook Pro using JDK 18.0.1.1

Read Multi Image tiff files

This needs the TiffDecoder class

File file = new File("/path/to/file");
TiffDecoder dec = new TiffDecoder();
int totalImages = dec.getImageCount(file);
    
for (int i = 0; i < totalImages; i++) {
   BufferedImage image = dec.readImageAt(i , file); // i is the image number

// Insert BufferedImage handling code here
}

Frequently asked questions

Does JDeli produce better TIFF reading and decoding than Java ImageIO?

Yes. While ImageIO can read TIFF, JDeli provides better compatibility, more consistent output across platforms, and access to format-specific decoding options.

Does reading or decoding TIFF in Java with JDeli require additional libraries?

No. JDeli is a 100% Java library with no dependencies. It runs on any platform where the JVM runs with no additional installation.

What input types does JDeli support for reading TIFF?

JDeli can read and decode TIFF from a File, InputStream, or byte array.

See also


Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Learn more about JDeli

Start Your Free Trial