How to read WebP files in Java

WebP file iconIn this article I will show you how to read WebP files in Java.

ImageIO and JAI do not have support for reading the WebP file format. In order to do so you need to find a third party library, for example luciad (can be cloned from here). Due to this lack of support we decided to create JDeli, which does not make use of ImageIO and allows you to read WebP images out of the box.

First an introduction to WebP images…

What is WebP?

WebP images were created by Google to work on web browsers. They are designed to be small and therefore fast to load, using both lossy and lossless compression. You can read more about the WebP image format in our previous article here.

To read a webp image using a third party library such as luciad:

BufferedImage image = ImageIO.read(new File("input.webp"));

To read a webp file using JDeli (Javadoc and download):

WebpDecoder decoder = new WebpDecoder();
BufferedImage image = decoder.read(webpByteData);

You can find more tutorials in our series on handling common image formats in Java, JDeli and other image libraries.

Related Posts:

The following two tabs change content below.

Bethan Palmer

Developer at IDR Solutions
Bethan is a Java developer at IDR Solutions and was a speaker at JavaOne 2016. She has a degree in English Literature and in her spare time enjoys sports including running and handball.

Latest posts by Bethan Palmer (see all)

Bethan

About Bethan Palmer

Bethan is a Java developer at IDR Solutions and was a speaker at JavaOne 2016. She has a degree in English Literature and in her spare time enjoys sports including running and handball.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>