The loading speed has long been one of the most important factors when op­ti­miz­ing a website, with visitors as well as search engines regarding the time it takes to call up a page as an important eval­u­a­tion criterion. A lean and com­pressed code or the use of caching mech­a­nisms are part of the tried and tested solutions for a fast Web presence, as is the use of com­pressed images. The latter – as design and back­ground elements – are included in many projects in large numbers, and their effect on the loading time is often un­der­es­ti­mat­ed.

The search engine giant Google among others, tackled this problem, and it presented its own license-free  image format for faster websites in 2010 - WebP. But what exactly is behind the web format that arose from the video codec VP8? And how does it do in direct com­par­i­son with es­tab­lished variables such as JPEG?

What is WebP?

On 30 September 2010, Google announced the release of a new open standard for lossy com­pres­sion of 24-bit graphics on the Web. The video format VP8 served as a model for the format with the name WebP, and this was developed by the company On2 Tech­nolo­gies, which Google had bought up in the same year. In the period following, Google extended the WebP format with features such as a lossless com­pres­sion mode, trans­paren­cy (alpha channel), and an­i­ma­tions. Chrome has supported the com­pres­sion format since the end of 2010, as has the browser Opera. But there are still a variety of browsers to date – such as Safari and Firefox – which have only supported WebP ex­per­i­men­tal­ly up to now, and do not offer support with their regular releases. According to its own in­for­ma­tion, Microsoft is currently working on support for its browser Edge.

Note

You will find con­tin­u­ous­ly updated in­for­ma­tion on WebP browser support at caniuse.com.

All software for the pro­cess­ing and pre­sen­ta­tion of WebP is under the BSD license as standard. Google uses the format, for example, in the Chrome Web Store, and in the mobile Google+ apps.

What char­ac­ter­is­tics dis­tin­guish WebP?

WebP has always served the purpose of reducing images on the Web to as small a file size as possible. According to in­for­ma­tion from Google, images and graphics in WebP format are around 30 per cent smaller than PNG or JPEG files with the same image quality. While both these classic Web formats rely on different com­pres­sion methods – PNG is lossless and JPEG lossy – WebP allows both options. Thanks to this flex­i­bil­i­ty, the format is suitable for photos as well as small images and graphics. The com­pres­sion features as well as the other central char­ac­ter­is­tics of the WebP format can be sum­ma­rized as follows:

  • Com­pres­sion (lossy): Lossy com­pres­sion with WebP uses keyframe coding of VP8.
  • Com­pres­sion (lossless): Lossless com­pres­sion with WebP is based on various tech­niques that transform the pa­ra­me­ters and image data. The LZ77 algorithm is also used here.
  • Trans­paren­cy: The 8-bit alpha channel that the WebP format offers can also be used for lossy RGB com­pres­sion.
  • Metadata: WebP may include EXIF and XMP metadata, which is typically generated by cameras.
  • Color profile: The Google format may contain embedded ICC profiles (data sets that describe the color spectrum).
  • An­i­ma­tions: The WebP format enables image sequences to be saved.

How does lossy WebP com­pres­sion work?

Lossy com­pres­sion with WebP uses the same method as the block-based VP8 codec, to predict frames – i.e. in­di­vid­ual images. Each frame is therefore divided into smaller segments, which are also described as macro-blocks. Within these macro-blocks, the coder can predict redundant movement and color in­for­ma­tion and subtract these from the block. The result of this pre­dic­tive com­pres­sion consists of the remaining block in­for­ma­tion and the separate redundant in­for­ma­tion (typically including many zero values). It is quan­ti­fied and entropy coded (pre­sen­ta­tion of char­ac­ters through specific bit pattern). The quan­tifi­ca­tion phase is the only process here in which the bits are actually discarded as lossy.

Note

WebP relies on an arith­metic coding method that is more effective than Huffman coding which is used with JPEG, for example. Both involve forms of entropy coding. However, the Huffman method assigns a whole number of bits to each character, while the arith­metic coding of the entire character string allocates a single longer bit code. The com­plex­i­ty is therefore higher with the arith­metic coding, but the gen­er­a­tion of bit location re­dun­dan­cies is excluded (only re­dun­dan­cy of complete messages).

Operating prin­ci­ples of lossless com­pres­sion with WebP

With lossless WebP com­pres­sion, the first step involves trans­form­ing the image. For this, the following tech­niques can be used:

Spatial Pre­dic­tion Transform WebP uses 13 different pre­dic­tion modes, which make use of the fact that neigh­bor­ing pixels fre­quent­ly correlate with one another. The current pixel value is predicted from already decoded pixels, and only the remaining value is coded.
Color Transform The aim of color transform is the decor­re­la­tion of the RGB values of each in­di­vid­ual pixel. Here the image is first divided into blocks, before red (R) is trans­formed based on green (G) and blue (B) based on green and red. The green value is kept as it is in the meantime.
Subtract Green Transform In addition to the general color trans­for­ma­tion, a variant is possible in which the green values are deducted from the red and blue values.
Color Indexing Transform If there are too few unique pixel values, the WebP format also provides the option of color indexing trans­for­ma­tion. The number of unique ARGB values in the image then becomes more definite, and creates al­lo­ca­tion of these values if the number is too small. This al­lo­ca­tion is used to replace the pixel values with the relevant index.
Color Cache Coding Loss-free WebP com­pres­sion can use image fragments already seen to re­con­struct new pixels . If there are no suitable hits here, a local color cache with the 32 last used colors serves as a starting point here. This is con­tin­u­ous­ly updated.

The trans­formed pa­ra­me­ters and image data are entropy coded, whereby a variant of the LZ77 algorithm is used. This uses small values for spatially close pixels.

What dis­tin­guish­es animated WebP?

Thanks to support from animated images WebP is an appealing al­ter­na­tive to GIF or APNG. Strengths come into play here such as the color depth of 24 bit and the 8-bit alpha channel, as well as the high degree of com­pres­sion. This enables the WebP format in contrast with the com­pet­i­tive formats in addition to the lossless as well as the lossy com­pres­sion of the an­i­ma­tions. Animated WebP is also con­vinc­ing in terms of decoding: As WebP metadata saves whether each frame contains alpha values, the decoder does not have to convert each frame in­di­vid­u­al­ly to receive this in­for­ma­tion.

Note

According to Google the con­ver­sion of GIFs into lossy WebP reduces the file size by up to 64 per cent, and for lossless WebP this is still 19 per cent.

The keyframe tech­nol­o­gy of the WebP format already mentioned shows its strengths, par­tic­u­lar­ly in an­i­ma­tions, where the key frames ensure high quality. However, for this reason, the decoding process is also more CPU-intensive than for GIF, for example.

How does the de­vel­op­ment of WebP look?

WebP files are container data, where the RIFF developed by Microsoft and IBM is relied upon as a container format: (Resource Inter­change File Format). A file in WebP format therefore consists of a RIFF header and the cor­re­spond­ing WebP content.

The RIFF/WebP header comprises the following three 4-byte series:

  • FourCC (four character code) “RIFF”: Type iden­ti­fiers from the four ASCII char­ac­ters R, I, F and F, which specifies that a RIFF container file is involved.
  • File size: Details on the size of the file
  • FourCCWEBP“: Type iden­ti­fiers from the four ASCII char­ac­ters W, E, B and P, which specify that the RIFF container includes a WebP file

The header is followed by the WebP file blocks, which are also described in RIFF con­tain­ers as “chunks”. Each chunk has its own header, to which the relevant in­for­ma­tion is attached. Possible blocks at the top levels are “VP8” (lossy WebP), “VP8L” (lossless WebP) and “VP8X” (extended WebP). The latter char­ac­ter­ize WebP files with ad­di­tion­al in­for­ma­tion such as EXIF metadata (“EXIF” chunk) or an ICCP color profile (“ICCP” chunk)) as well as animated WebP (“ANIM” chunk).

The complete de­vel­op­ment of files in WebP format looks as follows:

WebP vs. JPEG: WebP does well in com­par­i­son with the other image formats

JPEG or JPG is to the pre­sen­ta­tion of photos and large images on the World Wide Web what Google is to the world of search engines. Even a quarter of a century after its release, it is im­pos­si­ble to imagine the image format not being on the Web scene. The greatest advantage with regard to formats such as PNG – which is evenly dis­trib­uted but pre­dom­i­nant­ly used in smaller images and graphics such as logos, icons etc. – is without a doubt that JPEG ensures con­sid­er­able memory saving thanks to lossy com­pres­sion .

However, in this crucial detail WebP proves to be more efficient and more flexible. On the one hand, the Google format offers a lossless com­pres­sion method as well as a lossy one, while on the other hand, the memory saving for images in the WebP format out­per­forms that for JPEG images of the same value. The fact that JPEG permits images with a maximum size of up to 65,535 x 65,535 pixels, while the limit of WebP is only 16,383 x 16,383 pixels, can be ignored in light of the field of use (Web).

Note

The com­pres­sion advantage that WebP has compared to JPEG, is lost with a very strong com­pres­sion (from around a 90 per cent degree of com­pres­sion). While such com­pressed JPEG images are nev­er­the­less very pixelated, similar examples in the WebP format have a specific added value.

Similar to the com­par­i­son between WebP and JPEG is the com­par­i­son between WebP and GIF, where the format from Google also demon­strates con­vinc­ing ad­van­taged with regard to quality and com­pres­sion. However, the problem is with the lack of support for WebP from browsers such as Firefox or Microsoft Edge. To date, users of these web browsers do not see images and an­i­ma­tions in WebP, which is why barely any website operators rely on the format.

Basic data for the com­par­i­son of “WebP and JPEG” in table form:

WebP JPEG
Release 2010 1992
File extension (s) .webp .jpeg, .jpg
Maximum res­o­lu­tion (in pixels) 16,383 x 16,383 65,535 x 65,535
Com­pres­sion (lossless) Yes No
Com­pres­sion (lossy) Yes Yes
Trans­paren­cy (alpha channel) Yes No
RGB color spectrum Yes Yes
An­i­ma­tions possible Yes No
Sup­port­ing ap­pli­ca­tions limited (including Chrome, Opera, Gmail and IrfanView) Universal

How can WebPfiles be opened and converted?

File in WebP format cannot yet currently be opened with the usual image viewing programs from Windows, Linux and macOS If you want to view an­i­ma­tions or images which have been coded with WebP, there are various options.

If Chrome or Opera are installed on your system, you can simply drag the file in question into an open window on either browser. As these browsers support WebP natively, you can view the content you wish to open without requiring further software. However, this solution is not very con­ve­nient – par­tic­u­lar­ly if you want to view several images or an­i­ma­tions. If you do not want to have to work with various browser windows and switching between them, it's easier to use IrfanView, a freeware picture viewer which also offers WebP support after the in­stal­la­tion of the official plug-in package. However, the program is only available for Windows.

Note

If you use the Wine com­pat­i­bil­i­ty layer, you can also install IrfanView under macOS or Linux, to open WebPfiles with the freeware program.

Fur­ther­more, in the official WebP developer area Google offers a range of its own solutions for working with WebP – above all the libwebp library, which you can use to implement the WebP coding and decoding in your own programs. Also, the following tools are included in the free down­load­able col­lec­tion:

  • cwebp enables the com­pres­sion of an image field with the help of WebP. Possible input formats include PNG, JPEG and TIFF. In the tools options, you can define whether to use lossless or lossy com­pres­sion.
  • dwebp is a tool with which you can transform existing WebP files into other formats such as PNG (standard option), BMP, TIFF or PGM.
  • With vwebp, Google supplies its own solution for dis­play­ing WebP images and an­i­ma­tions based on OpenGL.
  • webpmux is the decisive tool for working with extended WebP. You can create an­i­ma­tions in WebP format, for example, with the program, or extend image files with metadata and ICC profiles.
  • With gif2webp you convert existing GIF files into WebP. As with regular image com­pres­sion, lossless as well as lossy coding is possible.
Tip

At ezgif.com you will also find a variety of tools for creating or con­vert­ing WebP files. In contrast to Google ap­pli­ca­tions, you can use these directly in the browser without in­stalling them.

Go to Main Menu