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.
Key information:
- 100% Java solution. No dlls or dependencies on native code
- Compression: CCITT 3,4, Pack bit, LZW, Adobe Deflate, JPEG technote2 and Deflate
- Colorspace: bilevel, grayscale, rgb, argb, cmyk, acmyk, ycbcr
- Bits Per Sample: 1 to 32
- Byte Ordering: Little and Big Endian
- Other: Single, Multi-file, Tiling, Planar (Chunky, Separated), Predictor, 16/32-bit floating samples
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);
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 | 6.601 | ± 0.119 |
| ImageIO | 7.976 | ± 0.140 |
| JDeli | 11.298 | ± 0.363 |
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.read(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.