This week we are going to tell you a few things about this latest newcomer in the world of image file formats named “WebP“.
The very beginning of the story is Google’s need for speed: seems that some 6 years ago Google engineers silently made an experiment in which they deliberately slowed down the delivery of search results by 100 to 400 miliseconds to cca. 1 million unaware users, for a few weeks.
The shocking conclusion of the experiment was that the less than 1% drop in searches produced by the less than half a second delay would generate hundreds of millions USD in lost revenues per year.
And as most of its profits comes from online advertising, the speed of content delivery became one of Google’s main priorities.
So no wonder they’ve soon introduced new features like auto-complete (suggestions for search terms changing as user is typing) or instant results (temporary results quickly served to user as he still types the search terms).
But they also made some other strategic, less obvious moves such as acquiring ON2 Technologies in 2010.
This small, yet publicly traded New York based Company was specialized in video codecs.
Video codecs are pieces of software designed to compress and decompress digital video information, aimed to allow the fastest rendering possible at the highest quality possible with as many handling/editing/securing features as possible.
Some well-known examples are DivX, Xvid, QuickTime, WMV but the complete list also includes VP8, one of ON2’s (now Google’s) creations.
Google turned VP8 from proprietary to open-source (not exactly surprising given that YouTube, its subsidiary, is the largest video sharing website in the world), hence its warmer feelings towards HTML5 video than for, say, Adobe Flash.
So yes, even if current HTML5 Video draft doesn’t specify which video formats should be natively supported by browsers (ie, without requiring plugins), one of them is certainly WebM “an audio-video container format designed to provide royalty-free, open video compression for use with HTML5 video, the project’s development being sponsored by Google Inc., a WebM file consisting of VP8 video and Vorbis audio streams” as Wikipedia puts it .
Now that was quite a long journey until finally reaching our actual WebP subject, n’est-ce pas ?
But it was also necessary because Google’s WebP image file format for web is a sister project of Google’s WebM project, it uses intra-frame compression techniques of VP8 codec and it is yet another product resulting from Google’s need for speed.
WebP (Wikipedia says we should pronounce it “weppy”) is a raster image format that uses both lossy and lossless compression techniques.
The compression algorithm was initially used in VP8 codec for compressing each frame of a video content so it can very well work on static images too, and we’ll try to give you a most simplistic description on how it works.
Remember our article explaining interpolation in bitmaps?
Well, WebP compression uses some similar interpolation/extrapolation idea.
It looks at a block of 16 pixels: by getting the color value of each pixel, based on the 16 values found, a powerful predictive algorithm tries to “figure out” what colors the 16 pixels of the adjacent block will have.
It then compares the “guess” with the real thing (ie, the actual colors).
If the match is perfect nothing happens.
If it’s not, the differences are being noted (stored).
So when a browser displays a WebP image file, it actually calculates the predictions adjusting them only if it’s the case by using the differences that have been stored in the file.
Even if there are really lots of calculations to do, the technique seems to perform extremely well, leading to 2 conclusions: 1) the predictive algorithm is really smart (way to go, ON2 and Google!) and 2) -from a browsers’ point of view- to render an image it’s easier/faster to make many complex calculations to obtain needed information than actually downloading it even through large bandwidths.
According to Google, real life tests performed in 2010 on a set of 1 million randomly gathered images (mostly JPGs but also PNGs and GIFs), showed that re-encoding to WebP format resulted in an average of 39% reduction in file size.
And even better results are to be expected if re-encoding starts from an uncompressed image.
See you next week!