{"canonical_url":"https://engineer.company/glossary/webp/","content_markdown":"# WebP\n\n## What it is\n\nWebP is a raster image format published by Google, stored in files with the\nextension `.webp` and served with the registered media type `image/webp`. One\nformat covers jobs that used to take three: photographs, which went out as JPEG;\nflat graphics with hard edges and transparency, which went out as PNG; and short\nloops, which went out as GIF. In prose it is written with a capital W and a\ncapital P, and on disk it is simply the `.webp` file.\n\nInside, a WebP file is a RIFF container, the chunked layout that WAV audio\nalso uses. It supports two image bitstreams. A `VP8` chunk carries lossy data,\nencoded with the key-frame method of the VP8 video codec: the encoder predicts\neach block of pixels from neighbours it has already decoded and stores only\nthe difference. A `VP8L` chunk carries lossless data, from a separate coder\nwritten for pictures that must come back bit for bit. A `VP8X` header marks\nthe extended form, which can add an alpha channel, animation frames, an ICC\ncolour profile and EXIF or XMP metadata. Google documented the format\nalongside its own library, and it has since been published as RFC 9649, an\ninformational RFC from November 2024.\n\nThe extended form is what makes the format more than a smaller JPEG. A lossy\npicture may carry a separate alpha channel, so a photograph with a soft,\ntransparent edge no longer has to be a heavy lossless file. Animation sits in\nthe same container, frame by frame, each frame lossy or lossless as suits it.\n\nThe image bitstreams have their own limits. Each side of an encoded picture or\nframe is stored in 14 bits, so it tops out at 16,383 pixels for lossy data and\n16,384 for lossless. The extended form can place frames on a larger canvas,\nand a whole file stays just under 4 GiB. Every channel is stored in 8 bits,\nwhich suits pictures meant for a screen and loses the extra depth of a 16-bit\nmaster.\n\n## Why it matters\n\nPictures are usually the heaviest bytes on a page, and the format decides how\nmany of them there are. Google's own comparison puts lossless WebP 26% below\nPNG, and lossy WebP 25–34% below JPEG at equal SSIM, a measure of structural\nsimilarity between two images. A lossy WebP with an alpha channel typically\ncomes to a third of the PNG it replaces. Fewer bytes reach the screen sooner on\na slow connection, cost less to serve, and leave room in a page's budget for the\nthings the reader came for.\n\nThe decision a team faces is less whether to use WebP than which format to ship\nfor which picture, and whether to ship more than one. Published averages stop\nhelping at that point. They are averages over a test corpus, while the files on\na real site are a logo, a handful of photographs and some screenshots, and the\nranking can come out differently for each. AVIF, the newer format, is the usual\nrival, and on paper it compresses harder. On a given site, at the sizes that\nsite renders, it may lose.\n\nThe second decision is where conversion happens. Converting by hand once leaves\na folder of files that drift away from their sources. Converting at build time,\nfrom an original kept in the repository, makes every published size reproducible\nand makes it cheap to change the quality setting, or the format, later.\n\nThe third is everything outside the browser. A picture's address travels: into\nfeeds, e-mail, chat previews, office documents and image editors, and each of\nthose decides for itself which formats it reads. A site that moves every picture\nto WebP learns which receivers accept it from the first reader who sees a broken\nimage, unless it checks each path first.\n\n## What it looks like in practice\n\nThe [credits page](/credits/) lists this site's pictures as WebP and PNG images,\nsized at build time. The templates show what that means. Inline photographs, avatars\nand the brand mark all pass through one shared partial that resizes the original\ninto several widths, each encoded as WebP, and writes a single `img` element\nwith a `srcset`, so the browser picks the width and the site has already picked\nthe format.\n\nThat format is a measurement rather than a default. The site's Hugo version\ncan encode AVIF, so serving both through a `picture` element was an option. In\nthe comparison documented on 17 August 2026, at the sizes the site rendered,\nAVIF came out 30–36% larger than WebP for the brain mark and 3–7% larger for\nthe avatars; it won only on the portrait, by 13%, and barely on the office\nphotographs, by 3–4%. A `picture` element chooses its source by order and by\nwhat the browser supports, never by size, so listing AVIF first would have\nsent every modern browser about a third more bytes for the logo on every page.\nWith one format worth shipping, the template uses `img` with `srcset` and no\n`picture` at all.\n\nThe same partial carries a second lesson. Hugo does not pass an image through\nwhen asked to resize it to the width it already has: it re-encodes it, making a\nsecond published file and, for a lossy original, another lossy pass. When a\nrequested width equals the original's, the partial therefore names the original\ndirectly by default. Callers that explicitly ask for every size to be derived\nstill re-encode it; the photo shortcode takes that path to avoid publishing a\nsecond copy of a master that is already served by the assets mount.\n\nWebP stops at the edge of what other software reads. The RSS feed points its\n`image` element at a PNG, because RSS 2.0 accepts only GIF, JPEG and PNG there\nand caps the picture at 144 by 400 pixels: the 1,280-pixel WebP share card\ndrew a warning from the W3C feed validator, and the 144-pixel apple-touch\nicon, a PNG at exactly the maximum width, took its place. The screenshots that\nthe English and Danish manifests hand to Chromium's install dialog, on the\nother hand, are WebP, a wide capture and a narrow one for each, and a lint\ntask fails when their recorded generation stamp trails a committed change to\nthe rendering inputs it tracks; uncommitted edits are outside that check.\n\n## Where it goes wrong\n\n**A converted JPEG loses detail twice.** Turning an existing JPEG into lossy\nWebP decodes one lossy generation and encodes another, and the artefacts of both\nsurvive. Hugo's resize-to-the-same-width behaviour is a quieter form of the same\ntrap. Keep a lossless or full-quality original in the repository and encode\nevery published file from that.\n\n**Colours turn dull after conversion.** `cwebp`, the reference encoder, copies\nno metadata unless told to, so the ICC profile of a wide-gamut photograph is\nleft behind and the browser treats the pixels as sRGB. Pass `-metadata icc`, or\nconvert the picture to sRGB before encoding.\n\n**A feed reader shows a broken picture.** Software written before the format, or\nheld to an older specification, treats a WebP as an unknown file. RSS 2.0 is the\nclearest case: its `image` element names three formats, and WebP is outside\nthem. Follow each place a picture's address travels, and serve PNG or JPEG where\nthe receiver demands it.\n\n**A long screenshot stops the encoder.** A full-page capture of a long article\neasily passes 16,383 pixels in height. The libwebp encoder caps each side at\nthat size, even though the lossless bitstream can represent one more pixel.\nSplit the capture, or scale it down first.\n\n**The bigger file wins the `picture` element.** Listing a newer format first\nsends it to every browser that decodes it, whether or not it is smaller for that\nimage. Measure each candidate at the sizes the page renders before adding a\nsource, as this site did with AVIF.\n\n## Further reading\n\n- [WebP](https://developers.google.com/speed/webp) — Google's home for the\n  format: the compression study behind the published percentages, the libwebp\n  library and its tools.\n- [RFC 9649: WebP Image Format](https://www.rfc-editor.org/rfc/rfc9649) — the\n  container, the lossy and lossless bitstreams, extended features and size\n  limits, as an informational RFC.\n- [cwebp](https://developers.google.com/speed/webp/docs/cwebp) — every option of\n  the reference encoder, including `-q`, `-lossless` and `-metadata`.\n- [Hugo: Image processing](https://gohugo.io/content-management/image-processing/)\n  — how a Hugo site resizes and converts images, WebP included, at build time.\n- [HTML Standard: Images](https://html.spec.whatwg.org/multipage/images.html) —\n  how `srcset`, `sizes` and `picture` let the browser choose among candidate\n  files.\n- [RSS 2.0 Specification](https://www.rssboard.org/rss-specification) — the\n  `image` element, the three formats it accepts and its size limits.\n\n\u003chttps://engineer.company/glossary/webp/\u003e\n","date_modified":"2026-11-12T05:34:23Z","description":"How WebP’s lossy and lossless modes differ, when it beats PNG, JPEG or AVIF on real files, and what breaks when a site converts its images.","formats":{"gemtext":"https://engineer.company/glossary/webp/index.gmi","gopher":"https://engineer.company/glossary/webp/gophermap","html":"https://engineer.company/glossary/webp/","json":"https://engineer.company/glossary/webp/index.json","markdown":"https://engineer.company/glossary/webp/index.md","pdf":"https://engineer.company/glossary/webp/index.pdf"},"kind":"page","language":"en","title":"What is WebP?","url":"https://engineer.company/glossary/webp/","version":1}