Up to $140 off-Lowest  Prices of 2024(Nov.21-Dec.2)

My Computer Tips

Home | About | Categories | All Tips & Tutorials

Convert image in .png format to .webp on Ubuntu and Ubuntu based distributions

ID: 296

Category: Ubuntu Mate

Added: 9th of December 2021

Updated On: Tutorial updated and rechecked on 1st of April 2024

Views: 2,594

The webp image format has been around for quite a few years, but I only recently found out about it. The Webp image format greatly reduces the file size without losing any quality over formats such as .gif, .png and jpeg.

Gimp on Linux already has this function to export as webp, but you can also install the webp package in Ubuntu or Ubuntu based distributions to convert images to the webp format using the terminal.

With the basic command for converting one image below, you could create a bash script to take a folder of .png images or mixed images and convert these .webp format.

To install webp enter the following command

sudo apt-get install webp


I decided to download the Tux image from https://commons.wikimedia.org/wiki/File:Tux.png which is saved in .png image and convert this to .webp format

Enter the following command
cwebp Tux.png -o Tux.webp


You can also convert images in .gif and .jpeg format to .webp

Below is the original Tux.png image, and below that is the Tux.webp image.
Quality wise they both images look identical, but more interestingly is the overall file size.

Tux.png image 11.9kb
Tux image, .png format (11.9kb)

Tux.webp image 4.6kb
Tux image, .webp format (4.6kb)

If your displaying a lot of images across your website in .webp format, you will make a considerable saving on the file sizes compared to .gif, .png, and .jpeg formats, which also means a faster download of all images for visitors to your website.

Please visit https://developers.google.com/speed/webp/gallery1 for further information about webp