Extreme Compression,
Retained Details.
WebP's compression efficiency comes from its block-based predictive coding. It uses parts of the image that have already been decoded to construct predictions for new pixels.
This means smaller file sizes, faster load times, and lower bandwidth consumption.
* Based on SSIM quality index, WebP lossy is 25-34% smaller than JPEG at equivalent quality.
Core Logic of Compression
function Predict(NeighborPixels) {
// Predict current pixel using neighbors
Predicted_P = Average(Left, Top, TopLeft);
// Store only the difference (Residual)
return Actual_P - Predicted_P;
}
WebP doesn't store every pixel's color directly (like BMP). Instead, it "guesses" the current pixel's color based on surrounding known pixels. It only needs to store the small amount of data where it "guessed wrong" (the residual). This drastically reduces file size.
All-Rounder Features
Not just a JPEG replacement, but an evolution of PNG and GIF.
Lossy & Lossless
WebP is unique in supporting both lossy compression (VP8 video tech) and lossless compression (WebP Lossless).
Alpha Transparency
Even in lossy mode, WebP supports an 8-bit Alpha channel. This is something JPEG cannot do.
Animation Support
WebP can replace GIF. It supports lossy and lossless animation, usually 64% smaller than GIF.
Underlying Architecture
Predictive Coding
WebP lossy compression is based on VP8 key frame encoding. It splits the image into 16x16 macroblocks and further into 4x4 sub-blocks for prediction.
Entropy Encoding
The residual data and motion vectors undergo context-based Arithmetic Coding, which is more efficient than JPEG's Huffman Coding.