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.
Mode: Throughput Count: 25 Units: ops/s
Benchmark | Score | Error |
---|---|---|
Apache | 363.988 | ± 9.254 |
ImageIO | 184.710 | ± 1.342 |
JDeli_better_comp | 1045.353 | ± 25.915 |
JDeli_better_speed | 1254.833 | ± 25.888 |
JDeli_deflate | 999.939 | ± 25.049 |
JDeli_jpeg | 1010.410 | ± 18.812 |
JDeli_LZW | 906.880 | ± 38.993 |
JDeli_uncompressed | 1961.287 | ± 36.406 |
Output files | File size AVG |
---|---|
Reference PNG | 6.383KB |
Apache | 674 bytes |
ImageIO | 1.898KB |
JDeli better comp | 1.438KB |
JDeli better speed | 1017 bytes |
JDeli deflate | 1017 bytes |
JDeli jpeg | 1018 bytes |
JDeli lzw | 985 bytes |
JDeli uncompressed | 1.896KB |
Tested on 2021 14inch M1 MacBook Pro using JDK 18.0.1.1