Brief: This guide shows you how to view WebP images in Linux and convert WebP images to JPEG or PNG format.
What is a WebP file?
It’s been over ten years since Google introduced WebP file format for images. WebP provides lossy and lossless compression and WebP compressed files are around 25% smaller in size when compared to JPEG compression, Google claims. Slowly and gradually, WebP is gaining popularity. CDNs automatically convert PNG files to WebP to server images in smaller sizes.
This is why when you download images from websites, they are downloaded in .wep format.
The problem is that GNOME Image Viewer, the default image viewer on mayn distributions does not support this format.
If you try to open a webp image, it opens the WebP image in a web browser. If you try top open with photo viewer, it throws an error:
Could not load image XYZ.webp
Unrecognized image file format
There are ways to get rid of this annoyance. In this tutorial, you’ll see:
- How to add WebP support to GNOME’s Image Viewer (recommended)
- How to use other tools for opening WebP files
- How to convert WebP images to PNG or JPEG
Let’s go through them one by one.
Method 1: Add WebP support to GNOME Image Viewer in Ubuntu and Other Linux (Recommended)
By default, the photo viewer does not support WebP images files. However, you can add WebP support by installing webp-pixbuf-loader library. Not only it allows you to open WebP files in GNOME Image Viewer, it also displays thumbnails for WebP files in the file explorer.
On Ubuntu-based Linux distributions, you can install this library using a PPA. Use the following commands one by one:
sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader sudo apt update sudo apt install webp-pixbuf-loader
In other distributions like Fedora and SUSE, you should be able to use the package manager and install it from the distribution’s repositories.
On Fedora, use:
sudo dnf install webp-pixbuf-loader
On Arch Linux, use:
sudo pacman -S webp-pixbuf-loader
Once it is installed, you don’t have to do anything else. No need to restart or log out. You’ll see that the WebP images are now displayed with thumbnails:
You should also change the default application in Ubuntu to open it with Image viewer with double click:
This is what I recommend but if for some reasons, you cannot install this additional library, you can use another application.
Method2: Use gThumb to view WebP images in Ubuntu and other Linux
One of the alternative photo viewer application is gThumb and it supports WebP images by default.
To install gThumb in Ubuntu and other Ubuntu based Linux distributions, use the command below:
sudo apt-get install gthumb
Once installed, you can simply rightly click on the WebP image and select gThumb to open it. You should be able to see it now:
Make gThumb the default application for WebP images in Ubuntu
For Ubuntu beginners, if you like to make gThumb the default application for opening WebP files, just follow the steps below:
Step 1: Right click on the WebP image and select Properties.
Step 2: Go to Open With tab, select gThumb and click on Set as default.
Method 3: Convert WebP images to PNG and JPEG in Linux
Since you are dealing with WebP images, you may want to learn about converting WebP to regular images.
There are two ways to convert WebP images in Linux:
- Command line
1. Using command line to convert WebP images in Linux
You need to install WebP tools first. Open a terminal and use the following command:
sudo apt-get install webp
Convert JPEG/PNG to WebP
We’ll use cwebp command (does it mean compress to WebP?) to convert JPEG or PNG files to WebP. The command format is like:
cwebp -q [image_quality] [JPEG/PNG_filename] -o [WebP_filename]
For example, you can use the following command:
cwebp -q 90 example.jpeg -o example.webp
Convert WebP to JPEG/PNG
To convert WebP images to JPEG or PNG, we’ll use dwebp command. The command format is:
dwebp [WebP_filename] -o [PNG_filename]
An example of this command could be:
dwebp example.webp -o example.png
2. Using GUI tool to convert WebP to JPEG/PNG
For this purpose, we will use XnConvert which is a free but not open source application. You can download the installer files from their website:
Note that XnConvert is a powerful tool that you can use for batch resizing images. However, in this tutorial, we shall only see how to convert a single WebP image to PNG/JPEG.
Open XnConvert and select the input file:
In the Output tab, select the output format you want it to be converted. Once you have selected the output format, click on Convert.
That’s all you need to do to convert WebP images to PNG, JPEg or any other image format of your choice.
What’s your pick?
I hope this detailed tutorial helped you to get WebP support on Linux and helped you to convert WebP images. How do you handle WebP images in Linux? Which tool do you use? From the above described methods, which one did you like the most?