In this tutorial, we explain what WebP is and how to convert images to this format in Ubuntu.
What is WebP?
WebP is a new image format which has been developed to offer a higher amount of compression without loss of image quality or with a slight loss of quality, which makes it ideal when we have to handle image subjects at the level of development or web.
For this tutorial, we will use Ubuntu 17.10.
In this case, the webp package is available in the official repositories of this distribution, so it will be possible to install it using the APT package manager in the following way:
sudo apt install webp
In the case of other Linux distributions, it is possible to download the webp package from the official Google Analytics repository using the wget command like this:
wget -c https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1-linux-x86-32.tar.gz
Then we can execute the following lines:
tar -xvf libwebp-0.6.1-linux-x86-32.tar.gz cd libwebp-0.6.1-linux-x86-32/ cd bin/ ls
To convert an image to a webp, it is possible to use the cwebp tool, using the -q parameter which defines the output quality and -o which specifies the output file using one of the following options:
cwebp -q 60 TheLinuxCode.jpg -o TheLinuxCOde.webp
Details of the image
- Dimension of the image
- Used bytes
- Created blocks
- Filter levels and more
If we want to visualize the WebP image, we can execute the following line:
If we're going to see all the WebP options, we can run the next line:
We can see how it is simple and useful to establish this new image format and in this way make the most of its benefits.