In the previous article We mentioned the image formats that are usually used on websites and defined which ones were appropriate for each case. Now we will discuss tools to create web images in Linux.
As the most common formats get by with Gimp and pre-installed viewers, We are going to concentrate on WebP and SVG formats
Tools to create web images in Linux
WebP
The WebP format is part of Google's attempts to gain complete dominance of the web. Supports both lossy and lossless compression.
In the early days of the Internet, slow connections meant finding ways to make images load quickly. It is then that two methods were developed:
- Lossy compression: The weight of the image is reduced by eliminating redundant information which affects the quality. As such, it is not a method that can be used for images that require high resolution. It can be used for images displayed on the screen.
- Lossless Compression: Instead of removing redundant information, compression is achieved through the use of algorithms.
Images in WebP format are up to 30% smaller than their PNG or JPG counterparts
How to create, edit and view images in WebP format
At least in Ubuntu Studio 23.10, Gimp can open, edit and save images in WebP format. We just have to add .webp to the file name and click Export. The options window allows us to select whether or not to save with loss and the type of image.
In general, KDE-based distributions will not have major problems since Gwenview, the native viewer can open it without problems. GNOME-based distributions will require the installation of a package.
For Ubuntu and derivatives we do it with:
sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader
sudo apt update
sudo apt install webp-pixbuf-loader
On ArchLinux
sudo pacman -S webp-pixbuf-loader
If we are Fedora users
sudo dnf install webp-pixbuf-loader
The same method applies to distributions based on the XFCE desktop.
For distributions using LxQT or Cinnamon, images should display without problems.
Converting images using the terminal
There are two commands that allow us to convert to and from the WebP format. We can install them with the following commands:
Ubuntu and derivatives
sudo apt install webp
Fedora and derivatives
sudo dnf install libwebp
We now have the following tools:
anim_diff – tool to show the difference between the images that make up an animation.
anim_dump – dump tool for the difference between animation images.
webp – tool to convert to WebP format
bebp – tool to convert WebP images to other formats.
gif2webp – tool to convert GIF animations to WebP
img2webp – tool to convert a sequence of images into a WebP animation.
vwebp – WebP file viewer for the terminal.
webpinfo – As the name suggests, it is useful for viewing information about a WebP image file.
webpmux – advanced WebP file manipulation tool
Examples
To convert from other file formats to WebP
cwebp -q <factor de compresión> <imagen de origen> -o <imagen_convertida.webp>
To convert from WebP to other formats
dwebp origen.webp -o destino
Remember that you must also indicate the file format of the destination image.
If you want to convert multiple images to WebP paste this in the terminal
for img in *.{jpg,png,gif}; do
cwebp -q FC "$img" -o "${img%.*}.webp"
done
Where FC is replaced by the compression factor
Remember that you can see all the possible uses of these commands by typing in the terminal
man nombre del comando.
As we said in the previous article, WebP has many possibilities. However, you should keep in mind that only the most modern browsers can handle it. It's all a matter of weighing the pros and cons.
In the next article we will fulfill the debt that remains from this article, mentioning the tools that allow us to manipulate files in SVG format. If you can't wait, try Inkscape.