+5 votes
321 views
How to convert images to WebP format on Linux

in Linux / Unix by (551k points)
reopened | 321 views

1 Answer

+3 votes
Best answer

One of the most versatile and used multimedia elements in the world is the images which we find by millions and in numerous formats. Just there, in the format, it is where the quality and attribute of the image is different, since although the image we see with the naked eye is the same, it can have a different size. Which is a sensitive issue when we must send an email , insert an image on a website or related tasks where optimal quality is required but with a light size..

We know multiple traditional formats such as JPG, PNG , etc., but a new format called WebP is being built and today we will analyze what it is and how to use it in Linux environments.

What is WebP?
WebP is a new image format which has been developed in order to offer a greater amount of compression without loss of image quality or with a slight loss of quality, which makes it ideal when we handle image themes at the development or web level.

When using the WebP format, webmasters and web developers have the ability to manage smaller images with better attributes which is reflected in a much shorter loading time of websites. Speaking with results, WebP lossless images are 26% smaller if we compare them with the PNG format and WebP loss images are 25 to 34% smaller than JPEG images in an SSIM quality index..

Lossless WebP compression makes use of predictive coding in order to encode an image, this being the same method used in the VP8 video codec to compress frames into videos. This type of predictive coding makes use of the values ​​in pixel blocks in order to predict the values ​​in a block, and then encode only the difference between them.

From this point of view, a WebP file is composed of VP8 or VP8L image data, and an RIFF-based container. The WebP format has native support in Google Chrome and in the Opera browser, as well as in many other current tools and software libraries..

When using the WebP format, a lightweight libwebp encoding and decoding library is included as well as the cwebp and dwebp command line tools to convert images to the WebP format.

For this example we will use Ubuntu 17.10 . In this case, the webp package is available in the official repositories of this distribution, so it will be possible to install it using the APT package manager as follows:

 sudo apt install webp 

image

Enter the letter S to confirm the download and installation of the application. In the case of other Linux distributions, it is possible to download the webp package from the official Google Analytics repository using the wget command like this:

 wget -c https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-0.6.1-linux-x86-32.tar.gz 

image

Then we can execute the following lines:

 tar -xvf libwebp-0.6.1-linux-x86-32.tar.gzcd libwebp-0.6.1-linux-x86-32 / cd bin / ls 

image

We can see that this precompiled library (libwebp) contains several elements to add web coding or decoding to multimedia elements and has several web utilities such as the following.

It is a tool to show the difference between the selected animation images
 anim_diff 
It is a tool to dump the difference between the chosen animation images
 anim_dump 

Refers to a web coding tool
 cwebp 

It is a webp decoder tool
 dwebp 

It is a tool that allows you to convert GIF images to webp
 gif2webp 

It is a group of tools to convert a sequence of images into an animated web file
 img2webp 

Refers to a webp file viewer
 Vwebp 

It is used to view information about a web image file
 webpinfo 

It is the webp mux tool
 Webpmux 

Thus, to convert an image to webp, it is possible to use the cwebp tool, using the –q parameter which defines the output quality and –o which specifies the output file using one of the following options:

 cwebp -q 60 TechnoWikis.jpg -o TechnoWikis.webp./cwebp -q 60 TechnoWikis.jpg -o TechnoWikis.webp 

image

Image Details
  • Dimension of the image
  • Used Bytes
  • Blocks Created
  • Filter levels and more

If we want to visualize the WebP image, we can execute the following line:

 vwebp TechnoWikis.webp 
If we want to see all the WebP options we can execute the following line:
 cwebp –longhelp 
image

We can see how simple and useful it is to establish this new image format and thus maximize its benefits.


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Nov 25, 2020 in Help by backtothefuture (551k points) | 250 views
+4 votes
1 answer
asked May 26, 2020 in Help by backtothefuture (551k points) | 1.1k views
+3 votes
1 answer
+4 votes
1 answer
asked Oct 21, 2022 in News by backtothefuture (551k points) | 40 views
+5 votes
1 answer
asked Nov 5, 2019 in Linux / Unix by backtothefuture (551k points) | 252 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,632 questions
10,764 answers
510 comments
3 users