Image Formats Explained: JPEG, PNG, WebP, AVIF

Picking the right image format is one of the highest-leverage performance decisions you can make. The wrong format wastes bandwidth, slows pages, and degrades visual quality. This guide compares the major web image formats and gives you a decision framework.

Format Comparison

FormatTypeTransparencyBest forNotes
JPEGLossy bitmapNoPhotographsUniversal support; tunable quality
PNGLossless bitmapYesScreenshots, icons, line artLarger files; perfect for sharp edges
WebPLossy or losslessYesMost web imagesCompare encoded size and quality
AVIFLossy or losslessYesHero images, large assetsCompare encoded size and quality
SVGVector XMLYesLogos, icons, illustrationsInfinite scale; CSS-stylable
GIFLossless animation1-bitLegacy onlyMP4/WebM often worth comparing

The Decision Framework

  1. Is it a logo, icon, or geometric illustration? → SVG.
  2. Does it need to be a small animation? → MP4 or WebM, not GIF.
  3. Is it a photograph or photographic asset? → AVIF primary, WebP fallback, JPEG for legacy.
  4. Does it need transparency or pixel-perfect edges (screenshots, UI assets)? → WebP lossless primary, PNG fallback.
  5. Is it a complex composite that needs both? → Use <picture> with AVIF → WebP → JPEG/PNG fallback.

The <picture> Pattern

<picture>
  <source srcset="hero.avif" type="image/avif">
  <source srcset="hero.webp" type="image/webp">
  <img src="hero.jpg" alt="..." width="1600" height="900" loading="lazy">
</picture>

With picture, the browser considers source order, media conditions, supported types and candidate selection rules. Keep the required img fallback; its sizing and alternative text still matter.

Typical Savings

  • JPEG → WebP: Savings depend on image and encoder settings.
  • JPEG → AVIF: Savings depend on image and encoder settings.
  • PNG → WebP lossless: Compare actual encoded sizes.
  • GIF animation → MP4: Compare size, playback and compatibility.

Getting Compression Quality Right

Format choice sets the ceiling; the quality setting decides where you land under it. A few rules that hold up in practice:

  • Photos (lossy): Compare several encoder settings at the intended display size. Quality scales vary by codec and encoder; no universal 75–85 setting is visually identical, and artifacts can occur at any lossy setting.
  • AVIF holds up lower: quality 50–60 often matches JPEG 80, so push it harder than you would a JPEG.
  • Flat graphics, screenshots, text: use lossless (PNG or WebP-lossless). Lossy compression turns sharp edges and coloured text into visible halos.
  • Resize before you compress. Serving a 4000px image into an 800px slot wastes far more bytes than any quality tweak — match pixel dimensions to the display size first.
  • Reserve the intended image space using dimensions or aspect-ratio. Consider lazy loading for noncritical offscreen images, but not an important immediately visible image; measure the result.

Try It Yourself

Resize and crop images for web with DesignKit's image tools.

Image Resizer →

Frequently Asked Questions

JPEG can suit photographs, while PNG can preserve rendered pixels and transparency without lossy encoding. Compare the actual files: JPEG artifacts and relative size vary, and modern formats may be preferable.
WebP is widely supported in current browsers. Compare encoded size, quality and target-browser compatibility; provide a fallback when required.
AVIF is a modern image format supported in many current browsers. Compare fidelity, size, decode cost and target compatibility; use an appropriate fallback.
SVG suits many vector logos, icons and illustrations. Embedded raster content does not gain detail when scaled, and complex SVGs may be larger or slower than raster alternatives.
Video formats can be more efficient than GIF for animation, but savings depend on the content and encoding. Consider autoplay behavior, controls, accessibility and where the file will be used.