Java WebP Writer
JDeli includes a WEBP Writer to write WEBP files in Java. The WEBP Encoder is written in 100% Java with no dependencies.
Key information:
- 100% Java solution. No dlls or dependencies on native code
- fast lossy compression
- Smaller file size
Quick start or to replace in existing code using ImageIO:
JDeli.write(myBufferedImage, "webp", outputStreamOrFile);
or
byte[] outputData = JDeli.write(myBufferedImage, "webp");
New method for quick and simple usage
JDeli.write(myBufferedImage, OutputFormat.WEBP, outputStreamOrFile)
OutputFormat allows setting of any supported Image Format
For complete control of output:
final WebpEncoderOptions options = new WebpEncoderOptions();
//set any options in options instance - examples below
options.setCompressionFormat(WebpCompressionFormat.LOSSLESS);
//write out
JDeli.write(myBufferedImage, options, outputStreamOrFile);
WebpEncoderOptions 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 | 217.441 | ± 14.804 |
JDeli | 200.908 | ± 11.554 |
JDeli_lossless | 287.432 | ± 23.937 |
Output files | File size AVG |
---|---|
Reference files | 470.33 bytes |
ImageIO | 231.33 bytes |
JDeli lossy | 362.67 bytes |
JDeli lossless | 377.69 bytes |
Tested on 2021 14inch M1 MacBook Pro using JDK 17.0.3