#formats · #webp · #avif · #jpeg-xl

WebP, AVIF or JPEG XL: which image format should you use?

A practical comparison of JPEG, PNG, WebP, AVIF and JPEG XL for photos, screenshots, transparency and compatibility — with honest browser caveats.

· 4 min read · LitPhoto

There is no single “best” image format. The right choice depends on where the image will be displayed, whether it needs transparency, whether it is a photo or a screenshot, and how much time you are willing to spend encoding.

Here is a practical decision guide for the formats LitPhoto can write, without inventing benchmark numbers.

The short answer

  • JPEG is the safest choice for photographs that must open everywhere.
  • PNG is for lossless graphics, screenshots, sharp UI edges and transparency.
  • WebP is a strong general-purpose format for web photos and graphics with broad modern support.
  • AVIF usually offers the smallest lossy photos, but encoding is slower and browser support is more dependent on the platform.
  • JPEG XL is efficient and supports lossless and high-quality modes, but in-browser display support is still the weakest of this group.

If compatibility is the priority, choose JPEG or PNG. If size is the priority and you control the viewing environment, WebP and AVIF are the usual candidates. Test the actual result before shipping it to a broad audience.

A comparison that focuses on use

Format Good for Transparency Lossless Main caveat
JPEG Photos, email, uploads, old devices No No Visible artifacts at low quality; no alpha
PNG Screenshots, line art, UI, exact pixels Yes Yes Large photographic files
WebP Web photos and graphics Yes Yes Slightly less universal than JPEG in very old software
AVIF Small lossy photos, modern web delivery Yes Yes Slower encode; decode/display support varies
JPEG XL Efficient lossless or high-quality archives Yes Yes Browser display support is limited

The table describes intended use, not a guarantee that every browser can preview every output. LitPhoto always offers the encoded file for download even when the preview falls back to a format plate.

Lossy vs lossless: the part that actually changes the file

Lossy formats discard information the eye is less likely to notice. A quality slider is not a percentage of “how good the photo looks”; it controls how aggressively the encoder throws data away. Two images with the same quality setting can produce different file sizes and different artifacts.

Lossless formats preserve every pixel. They are appropriate when the image is a screenshot, a diagram, a technical asset, or something that will be edited again. For photographs, lossless files are usually much larger and rarely necessary for web display.

WebP, AVIF and JPEG XL can be encoded both ways. LitPhoto exposes a lossless switch for those targets; PNG has its own lossless path. TIFF is effectively a lossless/professional target, which is why a TIFF conversion often produces a larger file than the original JPEG.

Transparency, animation and metadata

  • JPEG has no alpha channel. If the source is transparent, LitPhoto flattens it onto the chosen background colour.
  • PNG, WebP, AVIF and JPEG XL can carry alpha.
  • Animated GIF, APNG and animated WebP are processed as images, not video: only the first frame is kept in the current engine.
  • Metadata preservation is narrow. JPEG-to-JPEG and PNG/APNG-to-PNG/APNG can carry EXIF/ICC when the keep-metadata switch is on. Many cross-format conversions cannot, and the row shows a warning instead of silently dropping it.

How to choose in practice

  1. Will the image be viewed by an unknown audience? Start with JPEG for photos or PNG for graphics.
  2. Is it a web page where you control modern browsers? Try WebP first, then compare AVIF.
  3. Is every byte important and the viewer is modern? Test AVIF; keep a fallback if the image is critical.
  4. Is it a screenshot or an asset that will be edited? Use PNG or a lossless WebP/AVIF/JPEG XL output.
  5. Is it a professional intermediate file? TIFF or another lossless target may be the right output even if the file grows.

Do not choose a format only because a chart says it is “smallest”. Encode a few representative files, open them on the devices you care about, and check both quality and compatibility.

What LitPhoto can write

The browser build exposes 30 encodable formats out of 44 registered entries. JPEG, PNG, WebP, AVIF and JPEG XL use bundled WASM codecs. TIFF, PSD, TGA, QOI, DDS, EXR, HDR, JP2, SVG and other professional targets use an ImageMagick WASM engine loaded on demand.

HEIC, camera RAW, PDF and several desktop-only formats are visible in the format library but disabled for output, because a browser does not ship the required encoder. The app does not pretend those formats are available.

A reasonable default

For most people, WebP at smart quality is a good first attempt: it handles photos and transparency, keeps a familiar format, and usually produces a noticeably smaller file. If the result is larger than the source, LitPhoto keeps the original instead of handing you a worse file. From there, compare JPEG for compatibility and AVIF for size on the images that matter.

Try it locally

Every file is processed on your device. No uploads, no account, no tracking.
Open LitPhoto →