Amy Pearson Amy is a Java developer and member of the support team. Her main technical interests are JavaFX and Cloud. Out of hours she enjoys gaming and Virtual reality.

Comparing WebP compression algorithms

1 min read

WEBP icon

In this article we will be comparing the different compression methods available to use for WebP images. To do this, we will be using our Java image library, JDeli. We will be comparing file size, quality of output, and speed.

For the baseline of our comparisons, we will use the following uncompressed image. It has a file size of 180KB. It takes just under 3 seconds to encode.

What types of compression does WebP support?

Unlike most other image formats, WebP has both a lossless and lossy compression format. Which is best for you all depends…

What is Lossy compression?

Lossy compression is known as the irreversible compression due to the fact some data is removed.  The process uses the VP8 prediction code commonly used for videos which includes the algorithm DCT (Discrete cosine transform) to then be able to remove redundant data. This does mean quality loss can sometimes be expected but is usually not visible, also something to bear in mind you cannot return to the original quality once you have applied this compression. The advantage is that this compression can reduce the file size much more effectively.

Using lossy compression reduced the file size to 6KB and took just under 2 seconds, and the quality was set to a default of 75.

What is Lossless compression?

This compression unlike lossy, preservers the original data so when decoded can return the file to its original form. To achieve this, multiple transformations are made including several color transforms along with a spatial transform and then finished off by applying a form of entropy coding known as LZ77 huffman coding. This does then mean that the reduction in file size won’t be as significant but that is not always the most important aspect when compressing.

Using lossless compression reduced the file size to 67KB and also took just under 2 seconds.

Conclusion

As we can see the lossy far out ranks the lossless compression due to the much smaller file size for similar quality. If file size is your main focus lossy would be your first choice but if you want to be able to return to the original image than the hit of an extra 61KB wouldn’t matter as much especially when they both take the around the same time to complete.



Why do developers choose JDeli over free alternatives?

  1. Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP (AVIF next release) that are not supported in Java.
  2. Better support than alternatives for JPEG, PNG, TIFF.
  3. Process images up to 3x faster than ImageIO and other Java image libraries.
  4. Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  5. Image security as JDeli processes images on your servers with no calls to any external system or third party library.

Are you a Java Developer working with Image files?

Amy Pearson Amy is a Java developer and member of the support team. Her main technical interests are JavaFX and Cloud. Out of hours she enjoys gaming and Virtual reality.