JPEG, PNG, WebP or AVIF: which should you keep?
I have the same picture in four formats. Which one do I keep, and which do I delete?
Start with the picture, not the format
The format argument is almost always the wrong argument to have first. What decides the outcome is the content of the image. Photographs are made of smooth, noisy gradients with no repeated pixel runs. Screenshots, logos, diagrams and pixel art are made of flat areas, hard edges and a small number of exact colours. Those two kinds of picture compress by completely different mechanisms, and a format that is excellent at one is usually mediocre at the other.
So the first question is not "is AVIF better than JPEG". It is "is this a photograph or a graphic, and does it need transparency". Once you answer that, the shortlist is usually one or two formats long.
What each format actually does
| Format | Compression | Transparency | Animation | Best fit |
|---|---|---|---|---|
| JPEG | Lossy only | No | No | Photographs that must open anywhere |
| PNG | Lossless only | Yes, 8-bit alpha | No (APNG is a separate feature) | Screenshots, logos, flat graphics, exact pixels |
| WebP | Lossy or lossless | Yes, in both modes | Yes | A general replacement for both JPEG and PNG |
| AVIF | Lossy or lossless | Yes, including 10-bit | Yes | Photographs where encode time is acceptable |
The table hides one thing worth saying out loud: PNG cannot be made smaller by lowering a quality slider, because it has no quality slider. A PNG optimiser reduces the file by finding a better prediction filter and a better palette, not by discarding detail. That is why a photograph saved as PNG stays enormous no matter what tool you run over it — there is nothing in the format that lets it throw information away.
Lossy and lossless are not quality grades
It is tempting to read "lossless" as "good" and "lossy" as "bad". They are not quality grades, they are different jobs. Lossless means the decoded pixels are bit-for-bit identical to what went in; it is the right choice when the pixels are the point, as in a UI screenshot that someone will read text from. Lossy means the encoder is allowed to discard detail the eye is bad at noticing, which is the only reason a twelve-megapixel photograph can fit in a few hundred kilobytes at all.
A useful rule: if you would notice a single wrong pixel, use a lossless format. If you would not, a lossy format at a sensible quality setting will produce a far smaller file and you will not be able to see the difference at normal viewing size.
Where WebP and AVIF earn their place
Both newer formats use prediction and transform tools that JPEG, standardised in 1992, does not have. In practice that means they can reach a similar visual quality at a smaller size, and both handle transparency, which JPEG cannot do at all. WebP is the pragmatic one: it encodes quickly and it replaces both JPEG and PNG with a single format. AVIF is the ambitious one: it uses the AV1 video codec's intra-frame tools, supports higher bit depths, and generally gives the smallest file of the four for photographic content.
The cost is encode time. AVIF encoding is a search problem, and the encoder spends real CPU time on it. In a browser tab, on a phone, that time is yours — it is why FileSlimmer shows per-file progress for AVIF rather than pretending the wait is not happening. If you are converting one hero image, that trade is obviously worth it. If you are converting four hundred, consider WebP.
Converting an old file does not undo old damage
This is the single most common disappointment. If you take a JPEG that was saved at a low quality years ago and convert it to PNG or to lossless WebP, the blocking and ringing artefacts are copied faithfully into the new file. Lossless means "identical to the input", and the input already had the damage baked into its pixels. You get a larger file containing exactly the same flaws.
Converting a lossy file to another lossy format is a second, separate compression pass, so it can add its own artefacts on top. When you have a choice, convert from the most original file you still hold — the camera original, the export from the design tool — rather than from a copy that has already been through a compressor.
A shortlist you can actually use
- Photograph, needs to open in anything, including old software: keep JPEG.
- Photograph, for your own site or app, and you control what reads it: WebP, or AVIF if you can spend the encode time.
- Screenshot, logo, diagram, chart, or anything with text in the pixels: PNG, or lossless WebP if size matters more than universal support.
- Anything that needs a transparent background: PNG, WebP or AVIF. Not JPEG.
- An archive copy you may re-edit later: keep the original file, whatever it is, and treat every compressed version as disposable.
What this comparison does not tell you
There is no size ranking here, and that is deliberate. Published comparisons are measured on a particular image set, with particular encoder versions and settings, and the result moves when any of those change. Your own picture is the only test that describes your own picture. Convert the same source once to each candidate at a quality setting you find acceptable, then compare the two numbers and the two images side by side.
Support also changes over time. Before you commit a library to a newer format, check what has to open the files: a browser, a phone gallery, a printer, a customer's ten-year-old desktop application. The best format is the smallest one that everything in that list can actually read.
Tools for this
Sources
- ITU-T T.81 — the JPEG standard
- W3C — Portable Network Graphics (PNG) Specification (Third Edition)
- Google — WebP container and bitstream documentation
- Alliance for Open Media — AV1 Image File Format (AVIF)