The distinction in one line each
Lossless compression encodes the image so that decoding reproduces the original bit for bit. Nothing is discarded; the file is smaller purely because the data was described more efficiently.
Lossy compression discards information on purpose, choosing what to throw away based on what human vision is least likely to notice. Decoding produces something close to the original, never the original itself.
Everything else follows from that. Lossless files are bigger and safe to re-save indefinitely. Lossy files are far smaller and degrade a little every time they are re-encoded.
How lossless actually shrinks anything
It exploits redundancy. Real images are not random — neighbouring pixels are usually similar, and a good encoder predicts each pixel from the ones already decoded, then stores only the prediction error. In a flat region the error is almost always zero, and long runs of zero compress to nearly nothing.
PNG does exactly this. It applies one of several prediction filters per scanline, then runs the residual through DEFLATE. That is why PNG is superb on screenshots and interface graphics, where flat colour dominates and predictions are almost always right.
It is also why PNG is poor on photographs. Sensor noise means every prediction is slightly wrong, the residuals never compress to zero, and a 12-megapixel photo lands at 8 to 15 MB. The encoder is not failing — it is being asked to store genuinely unpredictable data without discarding any of it.
What lossy discards, and why you do not see it
JPEG converts blocks of pixels into frequency components: a few coefficients describing broad tonal shape, many describing fine detail. Human vision is far more sensitive to the former than the latter, so the encoder quantises the high-frequency coefficients aggressively and the low-frequency ones lightly.
In practice, most of what gets discarded is sensor noise and micro-texture — the pixel-level randomness that carries no information you were ever going to consciously see. That is why a 4 MB photo can become a 700 KB photo with no perceivable difference.
The failure modes appear when this assumption breaks. Sharp text edges are high-frequency detail that you absolutely do notice, which is why JPEG makes screenshots look dirty. Large areas of subtly changing colour expose the quantisation as visible banding, which is why skies suffer first.
Which format is which
Most formats are one or the other. Two are both, which is a genuine advantage.
- PNG: lossless only
- JPEG: lossy only
- GIF: lossless, but limited to 256 colours, which is itself a lossy step if the source had more
- WebP: both — lossless mode competes with PNG, lossy mode beats JPEG
- AVIF: both, with the best compression of the group and the narrowest support
- TIFF: usually lossless, occasionally lossy depending on how it was written
Generation loss is the practical trap
Every time a lossy file is decoded, edited, and re-encoded, it loses a little more. Crop a JPEG and save it, adjust the brightness and save again, send it through an app that re-compresses on upload, and you have stacked four generations of loss on an image that started fine.
The damage is not linear and it is not reversible. Converting the result to PNG afterwards freezes the degradation in place; it does not undo any of it.
The working rule: keep a lossless master, do all editing on it, and export to lossy once at the end for each destination. If you have already lost the master and only have the JPEG, minimise the number of further saves rather than trying to repair it.
Choosing without overthinking it
Photograph for display, no transparency needed: lossy. JPEG or WebP. The size difference is enormous and the quality difference is invisible at sensible settings.
Screenshot, diagram, logo, line art, or anything with crisp edges: lossless. PNG or lossless WebP. Lossy encoding puts ringing around every hard edge.
Anything with transparency: PNG or WebP, either mode. JPEG has no alpha channel and never will.
A master file you will edit again: lossless, always. Disk is cheap and detail is not recoverable.
An archive of something irreplaceable: lossless, and keep the camera original alongside it.
Why two lossless encoders give different file sizes
Lossless output is bit-identical when decoded, but the encoded file size varies a great deal between tools. The encoder is searching a space of possible filter and compression choices, and how hard it searches is a speed-versus-size trade-off.
For PNG, dedicated optimisers such as optipng and zopflipng routinely find 20 to 40 percent savings over a default export, with zero change to a single pixel. Most applications default to the fast path because nobody wants a save dialog to take ten seconds.
This is worth knowing because it means a PNG being large is not always evidence that PNG is the wrong format. Sometimes it is evidence that the exporter did not try very hard. Run an optimiser before concluding you need to go lossy.
Quality settings are not percentages
A JPEG quality of 50 does not mean the image retains half its quality, and quality 80 in one encoder does not match quality 80 in another. The number indexes into a quantisation table, and different implementations use different tables.
That is why advice phrased as a specific number is only ever approximate, and why the useful workflow is to look at the resulting file and its size rather than trusting the setting.
It also explains a frequent surprise: exporting at quality 100 does not produce a lossless file. The quantisation is minimal but still present, and the file is enormous for a difference nobody can see. Quality 95 is the sensible ceiling; above that you are paying a great deal for nothing.
Frequently asked questions
Does lossless compression reduce quality?
No. Decoding reproduces the original exactly, bit for bit. The file is smaller only because the data was described more efficiently.
Why is my lossless PNG so much bigger than a JPG?
Photographs contain sensor noise, which is unpredictable and cannot be discarded losslessly. PNG has to store all of it; JPEG is allowed to throw it away.
Can I convert a JPEG back to lossless?
You can put it in a lossless container like PNG, but the detail JPEG discarded is gone. That freezes the current state rather than recovering anything.
Is WebP lossless or lossy?
Both. Lossless WebP typically beats PNG by 25 to 35 percent; lossy WebP typically beats JPEG by a similar margin.
How many times can I re-save a JPEG before it looks bad?
It depends on quality and content, but degradation is cumulative and visible within a handful of generations at moderate quality. Keep a lossless master and export once.
Which should I use for a logo?
Lossless, and ideally SVG if it is vector artwork. For raster, WebP lossless or PNG — both keep the transparency and the crisp edges.