Webp images
What is WebP?
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. 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.
for Ubuntu 20.04 you can use:
sudo add-apt-repository ppa:krifa75/eog-ordissimo
sudo apt update
sudo apt install webp-pixbuf-loader
You’ll see that the WebP images are now displayed with thumbnails:
For Ubuntu 22.04 you should use:
sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader
sudo apt update
sudo apt install webp-pixbuf-loader
For Linux Mint 21.1 and Linux Mint LMDE5 you should use:
sudo apt install webp-pixbuf-loader
From now on Files wil show the contents of webp files.
Another program that can be used to see webp images is gthumb.
sudo apt-get install gthumb
Convert webp images to anything else:
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.
On Debian it is more complicated:
Enable WebP thumbnail and Open with Default Image Viewer:
For GNOME, XFCE, and other GTK based desktops, an open-source WebP GDK Pixbuf Loader library is available to enable WebP for default image viewer and thumbnail in file manager.
The library is not available in Debian and Ubuntu. And, below is how to build it from the source.
1. Install build dependencies:
Firstly, search for and open terminal either from start menu or from activities overview screen. When it opens, run command to install the required packages for building the library:
sudo apt install debhelper-compat meson libgdk-pixbuf2.0-dev libwebp-dev git
Type user password when it asks while no visual feedback and hit Enter.
2. Download webp-pixbuf-loader:
To grab the source, run git command in a terminal window:
git clone https://github.com/aruiz/webp-pixbuf-loader.git
3. Build & install webp-pixbuf-loader:
Now go to the source folder in terminal window:
cd webp-pixbuf-loader
Build the library by running the commands one by one:
meson builddir -Dgdk_pixbuf_query_loaders_path=/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders
ninja -C builddir
Finally install it via command:
sudo ninja -C builddir install
4. Set GNOME Default Eye of GNOME image viewer as default app to handle WebP:
After step 3, Debian shows thumbnails for WebP and supports for opening with the default EOG image viewer. If not for you, try log out and back in.
To make EOG as default app to handle WebP, run following commands one by one to update MIME database:
xdg-mime default org.gnome.eog.desktop image/webp
sudo update-mime-database /usr/share/mime
Install webp-pixbuf-loader on Ubuntu (and probably Debian as well) that has thumbnailer file the wrong place from gdk-pixbuf-thumbnailer. To fix it we have to replace it /usr/local/bin/gdk-pixbuf-thumbnailer with /usr/bin/gdk-pixbuf-thumbnailer in /usr/local/share/thumbnailers/webp-pixbuf.thumbnailer (both instances). You can do this manually using a texteditor like nano:
sudo nano /usr/local/share/thumbnailers/webp-pixbuf.thumbnailer
and remove the /local from both pathnames. Save the file using CTRL X
If you don’t see thumbnails for WebP images, you can try clearing the thumbnail cache (This will remove all thumbnails so they need to be regenerated):
rm ~/.cache/thumbnails/fail/gnome-thumbnail-factory/*.png
rm ~/.cache/thumbnails/normal/*.png
rm ~/.cache/thumbnails/large/*.png