WebP

WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.

WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.

Lossless WebP supports transparency (also known as alpha channel) at a cost of just 22% additional bytes. For cases when lossy RGB compression is acceptable, lossy WebP also supports transparency, typically providing 3× smaller file sizes compared to PNG.

— Google Developers1

The WebP was first announced and categorized under ‘Make the Web Faster’ by Google on 30 September in 2010.

The WebP support library(libwebp) was released version 1.0 in April 21, 2018.

WebP Support

WebP is natively supported in Google Chrome, Firefox, Edge, the Opera browser, and by many other2 tools and software libraries. Developers have also added support to a variety of image editing tools.

libwebp

The libwebp library, which can be used to add WebP encoding or decoding to your programs.

Download

All packages are available in Google’s downloads repostory, or search with package manager.

Utiliities

cwebp

cwebp compresses an image using the WebP format. Input format can be either PNG, JPEG, TIFF, WebP or raw Y’CbCr samples. Note: Animated PNG and WebP files are not supported.

Examples:

$ cwebp -q 50 -lossless picture.png -o picture_lossless.webp
$ cwebp -q 70 picture_with_alpha.png -o picture_with_alpha.webp
$ cwebp -sns 70 -f 50 -size 60000 picture.png -o picture.webp
$ cwebp -o picture.webp -- ---picture.png

dwebp

dwebp decompresses WebP files into PNG, PAM, PPM or PGM images. Note: Animated WebP files are not supported.

Examples:

$ dwebp picture.webp -o output.png
$ dwebp picture.webp -ppm -o output.ppm
$ dwebp -o output.ppm -- ---picture.webp
$ cat picture.webp | dwebp -o - -- - > output.ppm

vwebp

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

Examples:

$ vwebp picture.webp
$ vwebp picture.webp -mt -dither 0
$ vwebp -- ---picture.webp

webpmux

webpmux – Create animated WebP files from non-animated WebP images, extract frames from animated WebP images, and manage XMP/EXIF metadata and ICC profile.

Examples:

// Add ICC profile:
$ webpmux -set icc image_profile.icc in.webp -o icc_container.webp

// Extract ICC profile:
$ webpmux -get icc icc_container.webp -o image_profile.icc

// Strip ICC profile:
$ webpmux -strip icc icc_container.webp -o without_icc.webp

// Add XMP metadata:
$ webpmux -set xmp image_metadata.xmp in.webp -o xmp_container.webp

// Extract XMP metadata:
$ webpmux -get xmp xmp_container.webp -o image_metadata.xmp

// Strip XMP metadata:
$ webpmux -strip xmp xmp_container.webp -o without_xmp.webp

// Add EXIF metadata:
$ webpmux -set exif image_metadata.exif in.webp -o exif_container.webp

// Extract EXIF metadata:
$ webpmux -get exif exif_container.webp -o image_metadata.exif

// Strip EXIF metadata:
$ webpmux -strip exif exif_container.webp -o without_exif.webp

// Create an animated WebP file from 3 (non-animated) WebP images:
$ webpmux -frame 1.webp +100 -frame 2.webp +100+50+50 \
  -frame 3.webp +100+50+50+1+b -loop 10 -bgcolor 255,255,255,255 \
  -o anim_container.webp

// Get the 2nd frame from an animated WebP file:
$ webpmux -get frame 2 anim_container.webp -o frame_2.webp

// Using -get/-set/-strip with input file name starting with '-':
$ webpmux -set icc image_profile.icc -o icc_container.webp -- ---in.webp
$ webpmux -get icc -o image_profile.icc -- ---icc_container.webp
$ webpmux -strip icc -o without_icc.webp -- ---icc_container.webp

gif2webp

gif2webp converts a GIF image to a WebP image.

Examples:

$ gif2webp picture.gif -o picture.webp
$ gif2webp -q 70 picture.gif -o picture.webp
$ gif2webp -lossy -m 3 picture.gif -o picture_lossy.webp
$ gif2webp -lossy -f 50 picture.gif -o picture.webp
$ gif2webp -min_size -q 30 -o picture.webp -- ---picture.gif
$ cat picture.gif | gif2webp -o - -- - > output.webp