Bethan Palmer Bethan is a Java developer and a Java Champion. She has spoken at conferences including JavaOne/Code One, DevFest and NetBeans days. She has a degree in English Literature.

How to read WebP files in Java (Tutorial)

1 min read

WEBP icon

Why do WEBP Images cause issues for Java Developers?

ImageIO does not read WEBP file types by default so existing Java Applications will not work with them. If you have an existing Java Application using ImageIO you will find it cannot process these images.

In this post, I will cover how to upgrade ImageIO to support WEBP files so existing Java Applications which use ImageIO will work (often without having to make any code changes) and how to read WEBP files in JDeli directly.

What options are there for reading WEBP files in Java?

Java does not read WEBP images by default so you will need to use an external library or plugin for ImageIO. There are a range of Open Source and Commercial options available, including Java wrappers on non-Java solutions.

If you are looking for a free solution, there is an WEBP ImageIO plugin on GitHub (which includes Java wrappers). In this article we will be using our JDeli pure Java library to read WEBP files.

How to upgrade ImageIO to read WEBP files

It’s actually very simple and can be done without rewriting your existing code!

For example, the code below does not work with ImageIO for WEBP images


Steps to fix with JDeli:

How to read a WebP image in Java directly with JDeli

  1. Add JDeli to your class or module path. (download the trial jar).
  2. Create a File handle, InputStream pointing to the raw WebP image. You can also use a byte[] containing the image data.
  3. Read the WebP image into a BufferedImage

and the Java code to read WebP with JDeli…

Not sure if it’s working? Try print it out! If you see information about the image, it’s working!

Other useful WEBP links



Are you a Java Developer working with Image files?

Bethan Palmer Bethan is a Java developer and a Java Champion. She has spoken at conferences including JavaOne/Code One, DevFest and NetBeans days. She has a degree in English Literature.