Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:WebP

From ReverseEngineering.wiki
Format
Magic 52 49 46 46 ?? ?? ?? ?? 57 45 42 50 (RIFF, size, WEBP)
Extensions .webp
Endianness little
License specification is open; reference code libwebp is BSD-3-Clause
On this wiki Facts · Code · Notes · Topics

Google's image format (.webp): a little-endian RIFF container with form type WEBP holding a lossy VP8 key frame, a lossless VP8L stream, or an extended VP8X file with alpha, animation, ICC profile, Exif and XMP chunks.

Overview

A WebP file starts with a 12-byte RIFF header RIFF + u32 file size minus 8 + WEBP (RIFF_HEADER_SIZE 12 in src/webp/format_constants.h). Chunks follow as FourCC + u32 size + payload (padded to even). The reference decoder and encoder is Library:Libwebp.

Chunks

From doc/webp-container-spec.txt:

  • Simple lossy file: one VP8 chunk (the FourCC ends in an ASCII space, 0x20) holding a VP8 key frame.
  • Simple lossless file: one VP8L chunk.
  • Extended file: VP8X first (a 10-byte chunk, VP8X_CHUNK_SIZE; feature flags, then 24-bit canvas width-1 and height-1), then optional ICCP, ANIM and ANMF (animation control and frames), ALPH (alpha for a lossy frame), the image data, then EXIF and XMP . The spec requires VP8X, ICCP, ANIM, ANMF, ALPH, VP8 , VP8L to appear in that order. Feature flags in libwebp: animation 0x02, Exif 0x08, alpha 0x10, ICC 0x20 (mux_types.h). Maximum canvas size is 1<<24 per side (MAX_CANVAS_SIZE).

Bitstream markers

  • VP8L payload starts with the signature byte 0x2F (VP8L_MAGIC_BYTE), then 14 bits width-1, 14 bits height-1, 1 alpha-hint bit and 3 version bits (must be 0) (format_constants.h, doc/webp-lossless-bitstream-spec.txt).
  • A lossy VP8 key frame carries the start code 9D 01 2A after its 3-byte frame tag (src/dec/vp8_dec.c checks data[0..2] == 0x9d, 0x01, 0x2a).

Code & repositories

  • https://github.com/webmproject/libwebp @ 0464ce36981fc8169f69923eb6957dd46848967a · license: BSD-3-Clause
    libwebp source and specs: container spec, lossless bitstream spec, version constants in src/dec/vp8i_dec.h
    Tested on: source read, not run: read the source · checked 2026-10-18; last activity 2026-10-16

Pitfalls

  • The RIFF size must be consistent with the file; truncated downloads decode partially in libwebp.
  • A bare RIFF....WEBP check does not distinguish lossy, lossless and animated files; look at the first chunk FourCC.

Evidence & references

Read in https://github.com/webmproject/libwebp at commit 0464ce36981fc8169f69923eb6957dd46848967a: src/webp/format_constants.h, src/webp/mux_types.h, src/dec/vp8_dec.c, doc/webp-container-spec.txt, doc/webp-lossless-bitstream-spec.txt.