How to Convert Images to WebP Format in Linux

One of the numerous best practices you will hear of, for optimizing your web-site performance is using compressed images. In this article, we will share with you a new image format called webp for creating compressed and quality images for the web.

WebP is a relatively new, open source image format that offers exceptional lossless and lossy compression for images on the web, designed by Google. To use it, you need to download pre-compiled utilities for Linux, Windows and Mac OS X.

With this modern image format, webmasters and web developers can create smaller, richer images that make the web faster.

How to Install WebP Tool in Linux

Thankfully, the webp package is present in the Ubuntu official repositories, you can install it using the APT package manager as shown.

$ sudo apt install webp 

On other Linux distributions, start by downloading the webp package from Googles repository using the wget command as follows.

$ wget -c

Now extract the archive file and move into the extracted package directory as follows.

$ tar -xvf libwebp-0.6.1-linux-x86-32.tar.gz 
$ cd libwebp-0.6.1-linux-x86-32/
$ cd bin/
$ ls
Webp Packages

Webp Packages

As you can see from the above screen shot, the package contains a precompiled library (libwebp) for adding webp encoding or decoding to your programs and various webp utilities listed below.

  • anim_diff – tool to display the difference between animation images.
  • anim_dump – tool to dump the difference between animation images.
  • cwebp – webp encoder tool.
  • dwebp – webp decoder tool.
  • gif2webp – tool for converting GIF images to webp.
  • img2webp – tools for converting a sequence of images into an animated webp file.
  • vwebp – webp file viewer.
  • webpinfo – used to view info about a webp image file.
  • webpmux – webp muxing tool.

To convert an image to webp, you can use the cwebp tool, where the -q switch defines the output quality and -o specifies the output file.

$ cwebp -q 60 Cute-Baby-Girl.png -o Cute-Baby-Girl.webp
$ ./cwebp -q 60 Cute-Baby-Girl.png -o Cute-Baby-Girl.webp
Covert Image to WebP Format

Covert Image to WebP Format

You can view the converted webp image using the vwebp tool.

$ ./vwebp Cute-Baby-Girl.webp
View WebP Format Image

View WebP Format Image

You can see all options for any of the tools above by running them without any arguments or using the -longhelp flag, for example.

$ ./cwebp -longhelp

Last but not least, if you want to run the above programs without typing their absolute paths, add the directory ~/libwebp-0.6.1-linux-x86-32/bin to your PATH environmental variable in your ~/.bashrc file.

$ vi ~/.bashrc

Add the line below towards the end of the file.

export PATH=$PATH:~/libwebp-0.6.1-linux-x86-32/bin

Save the file and exit. Then open a new terminal window and you should be able to run all webp programs like any other system commands.

WebP Project Homepage:

Also check out these useful related articles:

  1. 15 Useful ‘FFmpeg’ Commands for Video, Audio and Image Conversion in Linux
  2. Install ImageMagick (Image Manipulation) Tool on Linux
  3. 4 Ways to Batch Convert Your PNG to JPG and Vice-Versa

WebP is just one of the many products coming out of Google’s continuous efforts towards making the web faster. Remember to share you thoughts concerning this new image format for the web, via the feedback form below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

8 Responses

  1. 01101001b says:

    Great article about a great image format. I use webp to save images because of its quality and lossless compression (better than jpeg, smaller than png). For instance an 1.6MB png image I just turn into webp resulted in a 327KB image file with no visible quality loss (needless to say, that ratio is not written in stone. No *magic* here).

    Webp has great advantages but drawbacks too. Clearly not every browser or image viewer supports it, so you must use judgement on when and where to use it.

    Furthermore, one annoying limitation is this format can only handle images up to 16383 x 16383 pixels, what is a problem if you need to capture some long webpages as images (sometimes the only way to preserve them faithfully).

  2. sylvain bosse says:

    Did download and try it. It worked well, but it work only with the png. I’ve tried to convert jpg to webp with no result. So this program need to evolve so it include jpg.

  3. Benedict Verhegghe says:

    An open source image format and you need Google’s precompiled binaries to use it, seriously?

  4. Sum Yung Gai says:

    Not sure why we need Yet Another Graphic File format (YAGF) when we already have several that work very well (.PNG and .JPG especially). What’s wrong with .PNG and .JPG?

    • Aaron Kili says:


      May be you need to try it out and you’ll find out why we actually need Yet Another Graphic File format (YAGF). Because it provides remarkable lossless and lossy compression for images on the web, making sites run faster.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.