This article will teach you all the information you need to convert and view WebP images in Ubuntu and other distributions.
Table of Contents
What is WebP
In September 2010, Google announced the WebP image format with a vision and a solid replacement for JPEG, PNG and GIF file formats. As you can see, it’s one single format that provides all the features of the legacy compression algorithm. At its core, WebP supports lossy, lossless animation and transparency.
In addition, WebP is based on block prediction technology and its recommended image format for the web. Due to its significant low file size and better quality, it became the modern standard for serving website images.
The Current State
Today, almost all the major web browsers support WebP – which means you can view the images in popular browsers such as Chromium, Chrome, Firefox, Brave, Vivaldi, Safari and Edge.
But creating a WebP image from existing JPG and PNG files requires the WebP library developed by Google. Moreover, the Linux distribution’s file managers are not yet capable of displaying them out of the box.
For a seamless integration and experience with WebP – many small components must work together. The operating system requires the core library for WebP. In addition, the file manager and image viewers need to recognise the *.webp
file type and read them.
All of these result in a consistent experience for users. Since it is still a new standard and adoption is in progress, you need to perform some extra steps in Linux to get it working.
On the other hand, Windows 10 and 11 currently support WebP by default, including its new Image Viewer.
Hence, this article will discuss how to view, create and convert WebP images in Linux systems.
View WebP Images
Ubuntu, Linux Mint and related distros
Viewing an image requires a loader. The file managers or image viewers use that loader library to enable the display of WebP images. By default, the WebP image loader is not available in Ubuntu Linux. Hence, you need to install the webp-pixbuf-loader
library using the following PPA to view a WebP image in Ubuntu. This library enables GTK applications to show the WebP images.
sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader
sudo apt update
sudo apt install webp-pixbuf-loader
If you want to learn how a GDK library works between the display server (e.g. X.Org) and GTK components, visit this page.
openSUSE
Leap and Tumbleweed packages are available here. Visit the page and click on the Expert Download to install.
Arch Linux
In Arch Linux, the package is available in the community repo. Hence the installation is easy using the following command.
sudo pacman -S webp-pixbuf-loader
Fedora Linux, RHEL
For Fedora and other related distributions, use the following command to install.
sudo dnf install webp-pixbuf-loader
After installation is complete, restart your system (optional).
Now, the fun part. Browse to any directory with WebP images, and you should see them in thumbnails or the default image viewer.
Here’s an example image with a before-after view of the Nautilus file manager in Ubuntu 22.04 LTS with WebP images.
View WebP images in Various File Manager/Image Viewers in Linux Distros
GNOME & Nautilus
For GNOME desktops, Nautilus would work fine with the method I explained above for Ubuntu/Fedora or others.
View WebP images in Thunar Desktop (Xfce-based distros)
Although Thunar can show the thumbnail by default for the Xfce desktop, the default image viewer Ristretto wouldn’t open the WebP. So, you must install the above packages first (Ubuntu/Fedora or Arch) and reboot. Then open it with Ristretto image viewer after changing the default .webp file-type association.
KDE Plasma – Dolphin file manager and image viewer – Gwenview
The default image viewer Gwenview supports WebP by default. Hence you don’t need any additional installation to view it. And Dolphin can display the WebP thumbnail just fine.
Viewing WebP images in PCManFMQt (LXQt-based distros)
If you are using Lubuntu, you should be able to open WebP by LXImage viewer because it supports WebP by default. Also, PCManFMQt can show WebP thumbnails by default.
Nemo file manager
Linux Mint is bringing WebP support from the Mint 21 “Vanessa” release onwards, which should work for the Nemo file manager. Until then, you can use the above PPA to view the WebP images in Linux Mint.
How to view WebP image in Ubuntu and other Linux using an app (recommended)
Firstly, the famous raster graphics program GIMP can open and save WebP images from version 2.10 onwards (currently available for all distros).
Secondly, you can use the following image viewers (other than what your desktop offers), which support WebP.
Finally, LibreOffice 7.4 (due in August) brings native WebP support for both import and export for its all components – Writer, Calc, Draw and Impress.
Convert WebP Images to JPG or PNG
Since you learned how to view the .webp files, it’s worth knowing how to convert them.
Firstly, install the webp packages for Ubuntu or Fedora Linux, including related distros using the following command. Alternatively, if you want the pre-compiled packages for all distros and operating systems which does not require installation, then visit this page and download the latest zip file.
Ubuntu and related distros:
sudo apt install webp
Fedora and related distros:
sudo dnf install libwebp
After installation, use the following command to convert a WebP image to JPG/PNG. Make sure to change the file name and path for your case.
dwebp image1.webp -o image1.png
Convert JPEG or PNG images to WebP format
Similarly, if you want to convert a JPEG or PNG file to WebP format, use the following command with cwebp (WebP encoder).
cwebp -q <compression factor> <input image> -o <output image>
For example, you can use a sample command below, which converts image1.png to image1.webp with a compression factor of 80
cwebp -q 80 image1.png -o image1.webp
Convert GIF image to WebP image
One of the underrated features of the WebP format is it supports animation. Hence, the animated GIF files can also work in WebP format with the same animation. Using the following command, you can convert an existing GIF file to a WebP file.
gif2webp input_file.gif -o output_file.webp
Visit this page to learn more about the above utility and other options.
Closing Notes
Although it’s been a decade since the first announcement of WebP, it took considerable time for desktop Linux to adapt to view the WebP image formats. And I believe, by 2022 end, the WebP support will be native, and you may not need additional tweaking or workaround to view or save WebP files.
I hope this article gives you complete detail about WebP and how you can make it streamlined for your workflow.
So, how you are managing WebP images today? Let me know in the comment box below.