Link
Skip to main content

Java WebP Writer

Java’s built-in ImageIO does not support writing WEBP files. JDeli is a 100% Java WEBP writer that provides full encoding control with no dependencies.

Getting started

Add JDeli to your project via Maven or Gradle, or see using JDeli with Java modules.

Key features:

  • 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");

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

Frequently asked questions

Can Java write WEBP files natively?

No. Java’s built-in ImageIO does not support writing WEBP files. JDeli provides a pure-Java WEBP encoder with no dependencies required.

Does writing WEBP in Java require native libraries?

No. JDeli is a 100% Java library with no dependencies. It runs on any platform where the JVM runs with no additional installation.

What output types does JDeli support for writing WEBP?

JDeli can write WEBP to a File, OutputStream, or return the encoded data as a byte array.


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