5 min read
Part of Series: Web Fundamentals & Standards

Image Formats for Web Performance

Master modern image formats including JPEG, WebP, AVIF, and PNG, understanding compression algorithms, color spaces, HDR support, and optimal deployment strategies.

FormatCompression Factor vs JPEGLossy/LosslessColor Depth (bits/chan)HDR & Wide GamutAlpha SupportProgressive/InterlaceBest Use CaseFallback
JPEGLossy8NoNoProgressive JPEGPhotographs, ubiquityJPEG
PNG-1.3n/a (lossless)Lossless1,2,4,8,16NoYesAdam7 interlaceGraphics, logos, screenshotsPNG
WebP1.25–1.34× smallerBoth8, (10 via ICC)NoYesNone (in-band frames)Web delivery of photos & UIJPEG/PNG
AVIF1.3–1.5× smallerBoth8,10,12PQ/HLG BT.2100YesAV1 tile‐basedHDR photography, rich mediaWebP → JPEG
JPEG XL1.2–1.5× smallerBothup to 32Full Rec.2100YesSaliency‐based prog.Web migration, archivingJPEG/WebP
HEIF/HEIC~2× smaller vs JPEGLossy/Losslessup to 16YesYesNoneiOS/macOS photos, burstsJPEG/PNG
JPEG 2000~1.2× better vs JPEGBoth8–16YesYesResolution + qualityPrint, medical imagingJPEG
GIFLimitedLossless8-color paletteNo1-bit4-pass interlaceSimple animationsAnimated PNG
TIFFVariesBothup to 32YesYesTiles/pyramidsArchival, professionalJPEG/PNG
BMPNoneNone (raw/RLE)up to 24NoNoNoneLegacy, universal supportPNG/JPEG

Digital imaging formats trade off between compression efficiency, color fidelity, dynamic range, feature support, and computational cost. Understanding their internal mechanisms—how data is stored, compressed, and decoded—empowers experts to select optimal formats for web delivery, professional workflows, or archival storage.

Storage: 8×8 pixel blocks → DCT → quantization → zig-zag scan → Huffman coding. Compression: Lossy; quality factor 0–100 scales quantization matrices. Color: YCbCr with 4:2:0 subsampling reduces chroma resolution. Progressive: Spectral selection → successive approximation passes. Limitations: Blocking artifacts at high compression; no alpha; 8 bit only. Use Case: Ubiquitous photographic delivery; fallback for modern formats.

Storage: Raw pixel data pre-filtered by one of five filter types → DEFLATE (LZ77+Huffman). Bit Depth: 1,2,4,8,16 bits per channel; truecolor, grayscale, indexed, alpha. Interlacing: Adam7 seven-pass for progressive detail. Alpha: 8 or 16 bit transparency. Limitation: Lossless means larger files; no HDR. Use Case: Graphics, text overlays, scientific data; transparency.

Architecture:

  • Lossy: VP8 intra-frame: 16×16 macroblocks → prediction → residual DCT → VP8 entropy.
  • Lossless: VP8L: predictive coding + local palette + Huffman. Color: YUV420; RGBA support via VP8L. Alpha/Animation: 8 bit alpha; frame differencing for animation. Compression: 25–34% smaller than JPEG at equal SSIM. Limitation: No HDR; moderate encoding complexity. Use Case: Immediate web adoption for mixed photo/UI assets.

Container: ISOBMFF HEIF. Codec: AV1 intra-frame: tiles, transforms, CDEF, loop filters, entropy (CABAC). Color: 4:2:0/2/4:4:4; RGB; 8–12 bit depth. HDR: PQ/HLG BT.2100; film-grain synthesis. Compression: 30–50% smaller vs JPEG; ~10% better vs WebP. Trade-off: 8–10× slower encode; multi-threaded decoding. Use Case: HDR photography, immersive media; progressive web where encoding time is secondary.

Modes:

  • VarDCT: Variable block-size DCT (2–256), XYB color quantization.
  • Modular: FLIF-inspired lossless; adaptive quantization. Features:
  • Lossless JPEG transcoding (20% size reduction).
  • Up to 32 bit/channel; HDR; ultra-high resolutions.
  • Saliency-based progressive decode using EBCOT. Performance: Decode >132 MP/s; encode ~50 MP/s in reference libjxl. Limitation: Experimental browser support. Use Case: Future-proof web, archival, layered editing.

Container: ISOBMFF; multiple images, sequences, metadata. Codec: HEVC Intra frames; Main/Main10 profiles. Color Depth: Up to 16 bit; HDR support. Features: Non-destructive edits, depth maps, image bursts. Compression: ~50% smaller vs JPEG. Limitation: Limited non-Apple support; licensing concerns. Use Case: Mobile photography (iOS default), computational photography.

Core: Tiling → DWT (CDF 9/7 for lossy, 5/3 for lossless) → quantization → EBCOT entropy. Features:

  • Resolution & quality progression; ROIs; alpha; metadata.
  • Lossless & lossy in one codestream. Compression: ~20% better PSNR than JPEG at same bitrate. Limitation: High complexity; poor web support. Use Case: Digital cinema, medical imaging, archival.

Core: LZW dictionary; 8 bit palette max. Animation: Frame differencing; disposal methods. Interlace: 4-pass pattern. Limitation: 256 colors; no HDR; crude transparency. Use Case: Simple animations, low-color graphics.

Container: Tag-based; supports LZW, ZIP, JPEG, PackBits. Features: Multi-page, tiling, pyramids, custom metadata. Use Case: Scanning, pro photography, geo-TIFF.

Storage: Uncompressed scanlines (bottom-up); optional RLE for 4/8 bit. Limitation: Very large; no compression. Use Case: Legacy Windows graphics.

Motivation: Native 10-bit/channel without 16-bit overhead. Packing:

  • Bytes 0–2: MS 8 bits of RGB.
  • Byte 3 bits 0–5: 2 LSBs of RGB; bits 6–7: 2 bit alpha. Compatibility: IHDR uses 8 bit flag + tEXt “segmented10bit” + sBIT “8 8 8 2.” Limitation: Non-standard; decoder updates required. Use Case: Future high-fidelity web graphics.
  • Legacy vs Next-Gen: JPEG/PNG universal but inefficient; WebP/HEIF/AVIF modern but require fallbacks.
  • Lossy vs Lossless: Lossy sacrifices data for size; lossless preserves fidelity at higher cost.
  • HDR & Gamut: Only HEIF, AVIF, JPEG XL, JPEG 2000 support true HDR & wide gamut.
  • Progressive Loading: Essential for perceived performance; supported variably.
  • Computational Cost: JPEG < WebP (2–3×) < AVIF (8–10×) ≈ JPEG XL moderate; JPEG 2000 high.

Format Stack:

  1. Photography: AVIF → WebP → JPEG
  2. Graphics/Logos: PNG 2.0 → WebP lossless → PNG 1.3
  3. Animation: WebP animation → MP4 fallback
  4. Archival: TIFF/JPEG XL lossless Implementation: Use <picture> & srcset for responsive, progressive enhancement with fallbacks.

Selecting an image format requires balancing compression, fidelity, feature support, and compatibility. Today’s experts should adopt WebP and AVIF for immediate web performance gains, plan for JPEG XL & PNG 2.0 as future standards, and maintain legacy JPEG/PNG support to ensure universal accessibility. Continuous monitoring of browser support and encoder optimizations will guide optimal format strategies.

Tags

Read more

  • Previous in series: Web Fundamentals & Standards

    Caching: From CPU to Distributed Systems

    10 min read

    Explore caching fundamentals from CPU architectures to modern distributed systems, covering algorithms, mathematical principles, and practical implementations for building performant, scalable applications.

  • Next in series: Web Fundamentals & Standards

    Web Accessibility

    13 min read

    Learn WCAG guidelines, semantic HTML, ARIA attributes, and screen reader optimization to create inclusive websites that work for everyone, including users with disabilities.