Link
Skip to main content

Java WebP Writer

The JDeli Java image library includes a WEBP Writer to write WEBP files in Java. The WEBP Encoder is written in 100% Java and provides WEBP support 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 with darkxanter 6.508 ± 0.044
JDeli_loss 3.659 ± 0.034
JDeli_lossless 4.632 ± 0.049

Number of files: 166

Benchmark Size unreadable output AVG SSIM score AVG Similarity
ImageIO with darkxanter 78.54KB 28 0.9764829133391945 Very similar (high quality)
JDeli lossy 1,506.67KB 2 0.9539262155199079 Very similar (high quality)
JDeli lossless 88.82KB 0 0.9684172944944212 Very similar (high quality)

Tested on 2021 14inch M1 MacBook Pro using JDK 17.0.3


Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Learn more about JDeli

Start Your Free Trial