Java JPEG2000 Writer
JDeli includes a JPEG2000 Writer to write JPEG2000 files in Java. The JPEG2000 Encoder is written in 100% Java with no dependencies.
Key information:
- 100% Java solution. No dlls or dependencies on native code
- Fast and easy to use
- Lossless and lossy supported
- JP2 or JPX output format
- Supports image compression settings
Quick start or to replace in existing code using ImageIO:
JDeli.write(myBufferedImage, "jpx", outputStreamOrFile);
or
byte[] outputData = JDeli.write(myBufferedImage, "jpx");
New method for quick and simple usage
JDeli.write(myBufferedImage, OutputFormat.JPEG2000, outputStreamOrFile)
OutputFormat allows setting of any supported Image Format
For complete control of output:
final Jpeg2000EncoderOptions options = new Jpeg2000EncoderOptions();
//set any options in options instance - examples below
options.setOutputSubtype(Jpeg2000OutputSubtype.JP2);
// or options.setOutputSubtype(Jpeg2000OutputSubtype.JPX);
options.setQuality(100);//0-100
//write out
JDeli.write(myBufferedImage, options, outputStreamOrFile);
Jpeg2000EncoderOptions 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 |
---|---|---|
ImageIO | 3.743 | ± 0.093 |
JDeli_JP2 | 4.243 | ± 0.305 |
JDeli_JPX | 4.401 | ± 0.087 |
Output files | File size AVG |
---|---|
Reference | 179.8KB |
ImageIO | 156.4KB |
JDeli JP2 | 85.6KB |
JDeli JPX | 121KB |
Tested on 2020 13inch M1 MacBook Pro using JDK 18.0.1.1