Link

Java TIFF Writer

JDeli includes a TIFF Writer to write TIFF files in Java. The TIFF Encoder is written in 100% Java with no dependencies.

Key information:

  • 100% Java solution. No dlls or dependencies on native code
  • Compression: Uncompressed, Deflate, JPEG, LZW
  • Access to xmp metadata
  • Single, Multi-file

Quick start or to replace in existing code using ImageIO:

JDeli.write(myBufferedImage, "tiff", outputStreamOrFile);

or

byte[] outputData = JDeli.write(myBufferedImage, "tiff");

New method for quick and simple usage

JDeli.write(myBufferedImage, OutputFormat.TIFF, outputStreamOrFile)

OutputFormat allows setting of any supported Image Format

For complete control of output:

final TiffEncoderOptions options = new TiffEncoderOptions();

//set any options in options instance - examples below
options.setCompressionFormat(TiffCompressionFormat.DEFLATE);
options.setXmpMetaData("xmp metadata");

//set Image resolution
tiffEncoderOptions.setResolutionUnit(TiffResolutionUnit.INCH);
tiffEncoderOptions.setXResolution(144);
tiffEncoderOptions.setYResolution(144);

//write out
JDeli.write(myBufferedImage, options, outputStreamOrFile);

TiffEncoderOptions allows setting of specific options.

Various image processing operations can be conducted on the image, detailed documentation can be found here.

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.

Benchmark Mode Cnt Score Error Units
TIFF.Apache thrpt 25 2.109 ± 0.060 ops/s
TIFF.ImageIO thrpt 25 18.693 ± 0.254 ops/s
TIFF.JDeli_better_comp thrpt 25 6.811 ± 0.081 ops/s
TIFF.JDeli_better_speed thrpt 25 38.698 ± 0.505 ops/s
TIFF.JDeli_deflate thrpt 25 15.225 ± 0.210 ops/s
TIFF.JDeli_jpeg thrpt 25 44.018 ± 0.770 ops/s
TIFF.JDeli_LZW thrpt 25 22.079 ± 0.152 ops/s
TIFF.JDeli_uncompressed thrpt 25 348.990 ± 16.928 ops/s
Output files File size AVG
Reference PNG 179.8KB
Apache 232KB
ImageIO 1.267MB
JDeli better comp 182.8KB
JDeli better speed 378KB
JDeli deflate 184KB
JDeli jpeg 36.2KB
JDeli lzw 247.6KB
JDeli uncompressed 1.267MB

Tested on 2021 14inch M1 MacBook Pro using JDK 11.0.16.1