Open In App

Converting Images to webp Open Source Format in Linux

In this article, we are going to see how to convert images to webp open-source format in Linux. Before starting, we will see the webp and its working process.

What is WebP?

How Does WebP work?

It is loss compression process uses the same methodology as VP8 (created by On2 technologies, which is a royalty-free video compression format) for estimating (video) frames. VP8 is based on block prediction & like any block-based codec. VP8 divides the frame into smaller segments called macroblocks. You don’t have to remember every technical jargon associated with this technology.



These macroblocks share the following 4 common intra-prediction modes :

Browsers that Support WebP Image Format:

  1. Google Chrome and all Chromium-based browsers,
  2. Firefox
  3. GNOME Web
  4. Midori
  5. Falkon

Note: WebP can also be displayed in all major browsers using the WebPJS JavaScript library, although support in Internet Explorer 6 and above is achieved using Flash.

WebP: Getting started

Download the pre-compiled packages for different OS(s) :

All the WebP packages are available in Google’s official downloads repository. Precompiled WebP utilities and library for download are also available :



Linux   click here  libwebp-1.1.0-linux-x86-64.tar.gz
Windows  click here libwebp-1.1.0-windows-x64.zip 
MacOS  click here libwebp-1.1.0-mac-10.15.tar.gz

How to use cwebp and vwebp tools ?

cwebP compresses the image using WebP format. 

The acceptable input format is:

  1. JPEG
  2. TIFF
  3. WebP
  4. Raw Y’CbCr samples

Note: Animated PNGs and WebP files are not supported.

Converting Images to the WebP Format using cwebp tool:

User can convert a PNG image file to a WebP image format with the quality range of 0 to 100 with the following command :

cwebp -q 80 image.png -o image.webp

In the above command, the quality compression factor is 80.

In the below example, using cwebp command without using -q option, so by default, it is 75.

Using cwebp to compress a 2.1 MiB jpg image to 983 Kib webp image (52% lossless compression)

The basic options are:

-o string

To explicitly specify the name of the output webp file. If this option is omitted, cwebp will perform compression but will only report the statistics using “-” as the name of the output file/image name.

-- string

To explicitly specify the input file. This option is useful only if the input image/filename starts with an ‘-‘.

-h, -help

A short usage summary.

-q float

To specify the compression factor for RGB channels between 0 & 100. By default, it is 75.

-z int

To switch on lossless compression mode with the specified level b/w 0 and 9, such that level 0 being the fastest and level 9 being the slowest.

The point to remember is that fast mode produces larger sizes than slower ones.

vwebp decompresses a WebP file & displays it in a window using OpenGL.

Decompressing a WebP file using vwebp tool:

Use vwebP on the command line to decompress webP file.

Decompressing webP file using no options :

vwebp picture.webp

Decompressing webP file using mt & dither option:

vwebp picture.webp -mt -dither 0

Decompressing webP file using — ( string ): Explicitly specify the input file if the input file starts with an ‘-‘ for instance. This option has to be used in last like any other options after this will be ignored. 

 Here filename is —picture.webp

vwebp -- ---picture.webp

Article Tags :