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?
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 this one:
BufferedImage image = ImageIO.read(new File("input.webp"));
//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
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