WebP's lossy image format is based on the intra-frame coding of the VP8 video format. It uses the Resource Interchange File Format (RIFF) as a container. It is a block-based transformation scheme with eight bits of color depth. The mandatory RIFF container has an overhead of only twenty bytes, though it can also hold additional metadata. The width of WebP images is limited to 16383 pixels.
WebP also has a lossless format that is claimed to be significantly better than even optimized PNG. It also supports transparency and animated images.
 How WebP Works
From their web site, slightly modified.
Lossy WebP compression uses predictive coding to encode an image, the same methodology used by the VP8 video codec to compress key frames in videos. Predictive coding uses the values in neighboring blocks of pixels to predict the values in a block, and then encodes only the difference (residual) between the actual values and the prediction. The residuals typically contain many zero values, which can be compressed much more effectively. The residuals are then transformed, quantized and entropy-coded as usual. WebP also uses variable block sizes. The colors are stored using the luminance-chrominance model where luminance is stored at full frequency and colors are reduced somewhat to larger areas.
Lossless WebP compression uses already seen image fragments in order to exactly reconstruct new pixels. It can also use a local palette if no interesting match is found. This palette is continuously updated to reuse recent colors. This compression mode is named "VP8L" and shares some common features with the so-called LZ77 compression algorithm.
A WebP file consists of VP8 or VP8L image data, and a container based on RIFF. The standalone libwebp library serves as a reference implementation for the WebP specification, and is available from their git repository and as a tarball.