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

1 min read


In 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 or JDeli. Due to this lack of support, we decided write our own WebP Decoder which is available as part of JDeli.

First an introduction to WebP images…

What is WebP?

WEBPWebP 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 this one:

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

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

//Read Image (can also be OutputStream or byte array)
File webpFile = new File("webpImage.webp"); 
BufferedImage image = JDeli.read(webpFile);

Or you can use the JDeli WebpDecoder directly:

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

Why use JDeli?

JDeli offers a range of advantages over ImageIO and alternatives, including:

  • prevents heap related JVM crashes
  • implements unsupported image formats
  • reduce output file size
  • improve read/write performance
  • supports threading
  • superior image scaling algorithms

Learn more about JDeli, or download to try it yourself.

Did you know...

IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?

It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page

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 convert WMF files to SVG in java…

This article will show you how to convert WMF files into SVG files using our JDeli Java Image library. What is WMF? WMF is...
Amy Pearson
1 min read

How to convert EMF files to SVG in Java…

This article shows you how to convert EMF files into SVG files using our JDeli Java Image library. What is EMF? EMF is a...
Mark Stephens
1 min read

Leave a Reply

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

IDRsolutions Ltd 2020. All rights reserved.