Java WebP Library — Read, Write & Convert WebP Files

Read, write, convert, and process WebP images in pure Java. No native code. Drop-in ImageIO replacement. Commercial license with dedicated support.

JDeli is a commercial, pure-Java image library that reads, writes, and converts WebP files with no native code or third-party dependencies. It works as a drop-in ImageIO replacement, so adding one JAR is enough to give your existing ImageIO.read() and ImageIO.write() calls full WebP support.

Quick Start

Get running in 30 seconds. Add the dependency, write one line, convert any WebP.

// Add IDR Solutions repository to your pom.xml
<repositories>
   <repository>
       <id>IDRsolutions</id>
       <name>IDR Solutions</name>
       <url>https://maven.idrsolutions.com</url>
   </repository>
</repositories>

// Add JDeli as a dependency
<dependencies>
    <dependency>
        <groupId>com.idrsolutions</groupId>
        <artifactId>jdeli</artifactId>
        <version>{YYYY.MM}</version>
    </dependency>
</dependencies>
// Add IDR Solutions repository to your build.gradle
repositories {
    maven {
        url = "https://maven.idrsolutions.com"
        name = "IDRsolutions"
        credentials(PasswordCredentials)
    }
}

// Add JDeli as a dependency
dependencies {
    implementation "com.idrsolutions:jdeli:{version}"
}

WebP Code Examples for Java

Copy-paste solutions to the exact problems Java developers search for.

// Read a WebP with alpha into a BufferedImage
BufferedImage image = JDeli.read(webpFile);

// Detect if the image has alpha
boolean hasAlpha = image.getColorModel().hasAlpha();
// Type 2 = TYPE_INT_ARGB when WebP contains transparency
int imageType = image.getType();
// Write a BufferedImage to WEBP with compression options
final WebpEncoderOptions options = new WebpEncoderOptions();

// Choose compression: Lossy or Lossless
options.setCompressionFormat(WebPCompressionFormat.LOSSLESS);

JDeli.write(myBufferedImage, options, outputFile);

// Or use Lossy — much smaller file size
options.setCompressionFormat(WebpCompressionFormat.LOSSY);

JDeli.write(myBufferedImage, options, outputFile);
// Convert WebP to JPEG with background fill for alpha
BufferedImage webp = JDeli.read(webpFile);

// JPEG has no alpha — composite onto a white background
BufferedImage rgb = new BufferedImage(
    webp.getWidth(), webp.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g = rgb.createGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, rgb.getWidth(), rgb.getHeight());
g.drawImage(webp, 0, 0, null);
g.dispose();

JDeli.write(rgb, "jpeg", outputFile);
// Resize a WebP to fit within target dimensions (preserves aspect ratio)
ImageProcessingOperations operations = new ImageProcessingOperations();
operations.resizeToFit(targetWidth, targetHeight);

JDeli.convert(inputFile, outputFile, operations);

// Or generate a thumbnail
ImageProcessingOperations thumbOps = new ImageProcessingOperations();
thumbOps.thumbnail(150, 150);

JDeli.convert(inputFile, outputFile, thumbOps);
// Strip WebP metadata by reading and re-writing
BufferedImage image = JDeli.read(inputFile);

// Write back — produces a clean WebP without the original ancillary chunks
WebpEncoderOptions options = new WebpEncoderOptions();
JDeli.write(image, options, outputFile);

Java WebP Library Comparison

An honest comparison. Where alternatives are equal or better, we say so.

Feature JDeli TwelveMonkeys darkxanter/webp-imageio
WebP Read ✅ Yes ✅ Yes ✅ Yes
WebP Write ✅ Yes ❌ No write support ✅ Yes
Lossy encoding ✅ Yes ❌ No write support ✅ Yes
Lossless encoding ✅ Yes ❌ No write support ✅ Yes
Transparency (alpha) ✅ Read & write ✅ Read only ✅ Read & write
EXIF read ✅ Yes ✅ Yes (standard metadata) ⚠️ Limited
EXIF write ✅ Yes ❌ No ❌ No
Quality setting ✅ Yes ❌ No write support ✅ Yes
Animation read ❌ Not supported ⚠️ Limited (frames only) ✅ Yes
Animation write ❌ Not supported ❌ No write support ✅ Yes
Cross-format convert ✅ One-line API ⚠️ Manual read/write ⚠️ Manual read/write
Native dependencies ❌ None (pure Java) ❌ None (pure Java) ⚠️ Requires libwebp native binary
libwebp CVE exposure ✅ Not affected ✅ Not affected ⚠️ Affected if libwebp < 1.3.2
ImageIO compatible ✅ Drop-in plugin ✅ ImageIO plugin ✅ ImageIO plugin
Image processing ✅ Resize, crop, rotate, etc. ⚠️ Resample only ❌ Encode/decode only
License Commercial (paid) BSD 3-clause (free) Apache 2.0 (free)
Commercial support ✅ Dedicated team, bug fixes in days ❌ Community only ❌ Community only
Other image formats 15+ (AVIF, HEIC, JPEG XL, PNG…) ~15 (no AVIF, HEIC) WebP only

Key takeaway: The JDK has no WebP support, so every Java developer needs a plugin or to attempt it in-house. TwelveMonkeys provides pure-Java read support, but no write support at all, which is a significant gap for any application that needs to produce WebP output. darkxanter/webp-imageio fills the write gap but introduces a native libwebp dependency, which brings deployment complexity and security exposure. JDeli is the only option that covers reading, writing, EXIF, quality control, and image processing in a single pure-Java library, without native code on the classpath.

WebP Benchmarks

Measured with JMH on GitHub. Run them yourself, the code is public and the tests work on the trial version.

Throughput mode, 25 measurement iterations, units in operations per second. Higher is better.

WebP Reading (ops/s)

Library Throughput (ops/s) Error
JDeli 0.950 ± 0.073
TwelveMonkeys 0.877 ± 0.107
darkxanter/webp-imageio 16.933 ± 0.185

WebP Writing (ops/s)

Library / Mode Throughput (ops/s) Error
JDeli — lossy 3.659 ± 0.034
JDeli — lossless 4.632 ± 0.049
darkxanter/webp-imageio — lossy 6.058 ± 0.141
darkxanter/webp-imageio — lossless 1.067 ± 0.028

Output Size & Quality

Library / Mode Total Size Unreadable Output Avg SSIM Similarity
JDeli — lossy 0.53 KB 0 0.942003 Similar (noticeable but minor differences)
JDeli — lossless 9.08 KB 2 0.954074 Very similar (high quality)
darkxanter/webp-imageio — lossy 8.86 KB 28 0.978351 Very similar (high quality)
darkxanter/webp-imageio — lossless 0.57 KB 28 0.959870 Very similar (high quality)

WebP Format Support in Depth

Lossy Compression

JDeli supports lossy WebP encoding with a configurable quality setting, giving you precise control over the file-size-to-quality trade-off. Lossy WebP typically achieves significantly smaller files than JPEG at equivalent visual quality, making it well suited for web delivery, thumbnail generation, and batch image pipelines.

Lossless Compression

JDeli also supports lossless WebP encoding, which preserves pixel-perfect image data. Lossless WebP typically produces smaller files than equivalent PNG, making it a strong choice for UI assets, icons, and any pipeline where fidelity must be guaranteed.

Transparency (Alpha Channel)

JDeli reads and writes WebP images with full alpha channel support in both lossy and lossless modes. Unlike converting alpha-bearing images through JPEG, which infamously produces a red or pink tint, JDeli handles transparency correctly at every step with no manual pre-processing required.

EXIF Metadata Read & Write

JDeli reads and writes EXIF metadata embedded in WebP files. Camera settings, orientation, GPS coordinates, and other EXIF fields are preserved across read/write cycles and are accessible through a clean API, with no need to traverse a DOM tree of IIOMetadata nodes and no loss of metadata when re-encoding.

Quality Control

JDeli exposes an explicit quality parameter for lossy encoding so you can tune output to match your application's requirements precisely. Whether you need maximum compression for bandwidth-constrained delivery or near-lossless quality for content review pipelines, a single parameter covers it with no opaque internal defaults.

Animation — Not Supported

JDeli does not currently support reading or writing animated WebP files. If animated WebP is a requirement, this is an important limitation to be aware of. For all other WebP workflows, including read, write, convert, process, and EXIF, JDeli is a fully capable pure-Java solution.

Why JDeli is the Clear Choice for WebP in Java

The JDK has no WebP support, so every Java team needs to add something. Here is why JDeli is the right choice.

Covers the gap the popular options leave

TwelveMonkeys only reads WebP, it doesn't write it. darkxanter/webp-imageio adds write support but wraps Google's native libwebp library, bringing platform-specific binaries into your build. JDeli reads and writes WebP in one pure-Java library.

No exposure to libwebp's CVE history

In 2023, a critical buffer overflow in libwebp (CVE-2023-4863) was actively exploited before a patch existed, with a maximum CVSS score of 10.0. Anything wrapping libwebp inherited that risk. JDeli has no dependency on libwebp and has never had a CVE.

No native binaries to break in production

JNI wrappers like darkxanter/webp-imageio need a platform-specific native binary at runtime. JDeli is a single JAR that runs anywhere Java runs.

EXIF write, not just read

Neither TwelveMonkeys nor darkxanter/webp-imageio can write EXIF data back to a WebP file, which matters for camera apps and DAM pipelines that need to preserve metadata. JDeli reads and writes EXIF natively.

Simple conversion, no alpha workarounds

Converting WebP to JPEG with the alternatives means handling the alpha channel yourself to avoid the well-known red tint bug. JDeli converts formats in one line and handles that automatically.

Image processing built in

darkxanter/webp-imageio only encodes and decodes. JDeli includes resize, crop, and rotate out of the box, so common tasks don't need an extra library.

Commercial support, not a GitHub issue queue

TwelveMonkeys and darkxanter/webp-imageio are community maintained, so fixes happen when they happen. JDeli ships a release every 6 weeks, sometimes with bugs typically fixed within days of a reproducible report.

One library for 15+ formats

darkxanter/webp-imageio only handles WebP. JDeli also covers AVIF, HEIC, JPEG XL, PNG, TIFF, and more, so one dependency can replace several.

Read, Write and Convert WebP files in pure Java with JDeli

JDeli helps unlock the potential of the file format with a few lines of Java code:

// Read WebP files

JDeli.read(File webpFile);

JDeli.read(byte[] webpData);

JDeli.read(InputStream webpStream);
// Write WebP files

// To a File
JDeli.write(myBufferedImage, "webp", new File("output.webp"));

// To an OutputStream
JDeli.write(myBufferedImage, "webp", outputStream);

// To a byte array (returns the encoded bytes)
byte[] webpData = JDeli.write(myBufferedImage, "webp");
// Convert to and from WebP files
JDeli.convert(File inFile, File outFile);

JDeli.convert(InputStream inStream, OutputStream outStream, String format);

byte[] outputData=JDeli.convert(byte[] inputData, String format);

Trusted by Companies around the World

Abacus logo
Citi logo
Clearsense logo
Honeywell logo
Los Alamos National Lab logo
Mercedes-Benz Bank logo

JDeli handles not only HEIC but other types of file formats as well.

- Joselito M. (Senior Applications Developer at Omaha National)

Frequently asked questions

Does Java ImageIO support WebP?

No. Java’s ImageIO has no support for WebP. JDeli adds full support for reading and writing WebP and handling for lossy and lossless compression.

Can I convert a PDF to WebP in Java?

JDeli does not read PDF files. To convert PDF pages to webp in Java, use JPedal. See Convert PDF to webp in Java.

How do I convert WebP to JPG in Java?

Call JDeli.convert(new File("input.webp"), new File("output.jpg")). JDeli infers the output format from the file extension. See Convert webp to JPG in Java for a full example.

How do I convert WebP to PDF in Java?

Call JDeli.convert(new File("input.webp"), new File("output.pdf")). JDeli infers the output format from the file extension. See Convert webp to PDF in Java for a full example.

Why use JDeli for WebP image support?

1.

Pure Java, no native code, no libwebp or native security risks, no deployment surprises

2.

Full read, write, EXIF, and quality control, where alternatives have gaps

3.

Drops into existing ImageIO code and covers 15+ other formats too

Try JDeli for Free