WebP Images for Android projects

Two weeks ago (2 March 2017) Google announced the support of its new images format for Android with Android studio 2.3 and recommended users to start migrate their PNG/JPG images to the new WebP format.

With some searching, i found it a great tool to decompress your image files, but it wouldn't be that efficient for the small projects, or the projects that uses most of their assets loaded from the internet.

Let’s introduce first what is the WebP image format:

WebP is an image file format from Google that provides lossy compression (like JPEG) as well as transparency (like PNG) but can provide better compression than either JPEG or PNG.

Limitations for WebP images with Android:

Lossy WebP images are supported in Android 4.0 (API level 14) and higher, and lossless and transparent WebP images are supported in Android 4.3 (API level 18) and higher, so you can use the lossless algorithm only with applications that working with 4.3 and higher.

How can you migrate your drawable images with Android studio

First: press right click on your image file in the drawable directory, and choose “convert to WebP”

Second : you will find the following dialogue, you can keep the default settings and move on… or you can change to lossless if you are 4.3 or higher , also you can change the encoding quality.

After pressing OK, You can find The number of bytes saved from the compression in the right bottom notification in Android studio.

You can find a quick analytics applied on a small/med project, the first image shows the apk size before using WebP image format (2.1 MB), and the second image shows the apk size after migrating all the PNG files to WebP (2.0 MB), which is 5% apk size saved, it would be more efficient if your project depends on high quality images.

Before compression
After compression

In the end, I recommend to migrate your drawables to the new WebP Image format to decrease your images size as the WebP lossless format is up to 25% smaller, and to decrease your apk size too.

The (retired) Pub(lication) for Android & Tech, focused on Development