WebP Recompression vs JPEG XL Lossless Transcoding

Migrating legacy JPEG images to modern image formats is essential for reducing bandwidth and accelerating web performance, but the methods used by WebP and JPEG XL differ fundamentally. While converting a JPEG to WebP requires decoding the image to raw pixels and re-encoding it—a process called recompression—JPEG XL can directly rewrite the JPEG bitstream into its own format without decoding. This article examines the technical mechanics, visual fidelity, reversibility, and performance differences between WebP recompression and JPEG XL lossless transcoding.

The Recompression Process in WebP

Converting an existing JPEG to WebP requires a full decode-and-re-encode pipeline:

  1. Decoding: The source JPEG is fully decoded into uncompressed pixel data (RGB or YUV).
  2. Analysis and Re-encoding: The WebP encoder analyzes these raw pixels and applies its own compression algorithms, utilizing spatial prediction, transform coding (VP8 intra-frame coding for lossy WebP), and entropy encoding.

Because the encoder evaluates pixels rather than the original frequency data, the process introduces generational loss if lossy WebP is chosen. Compression artifacts from the original JPEG are treated as genuine image detail by the WebP encoder, which attempts to preserve those artifacts at the expense of compression efficiency or introduces new artifacts on top of the old ones. Alternatively, using WebP lossless on raw pixel data decoded from a JPEG typically results in a file size significantly larger than the original JPEG.

Lossless Bitstream Transcoding in JPEG XL

JPEG XL approaches existing JPEGs through native bitstream transcoding rather than pixel-level recompression:

  1. Direct Parsing: JPEG XL parses the existing discrete cosine transform (DCT) coefficients, quantization matrices, and Huffman metadata directly from the JPEG file.
  2. Direct Mapping: Instead of rendering pixels, JPEG XL maps these 8x8 DCT blocks directly into its own VarDCT (Variable-block-size DCT) structures.
  3. Advanced Entropy Coding: The parsed coefficients are re-encoded using JPEG XL’s entropy coding mechanism (context-adaptive ANS or Brotli-based entropy coding), which is substantially more efficient than legacy JPEG Huffman tables.

This process operates strictly on mathematical representations rather than raw pixel buffers, requiring far less computational power than re-encoding.

Visual Fidelity and Generational Loss

Reversibility: Byte-for-Byte Restoration

A defining difference between the two formats is reversibility:

Performance and File Size

JPEG XL transcoding reduces existing JPEG file sizes by roughly 16% to 22% while guaranteeing exact bitstream preservation. The operation is extremely fast because it bypasses motion estimation, frequency analysis, and color conversion.

WebP can often achieve greater size reductions (25% to 35%) when converting from JPEG, but it does so by sacrificing data fidelity via lossy approximation. Achieving these smaller sizes requires intensive CPU usage during the re-encoding phase to tune compression parameters and avoid introducing noticeable secondary artifacts.