How compression affects quality
Compression reduces the amount of data stored in a file. There are two kinds, lossless and lossy, and which one applies depends on the format and the settings you choose. The difference matters, because one of them is reversible and the other is not.
Written by Jay Sudha · Published · Last updated
Lossless compression
Lossless compression reduces file size without discarding any information. The file is encoded more efficiently so that when it is uncompressed, the original data is perfectly restored.
PNG images use lossless compression. A compressed PNG will look identical to the original; it is just stored more compactly. ZIP archives work the same way: packaging files into a ZIP reduces total size without changing a single byte of what comes out the other end.
Lossless compression works by finding redundancy. A large block of identical colour, a repeated string of text, a predictable pattern; these can be described more briefly than they can be listed. The corollary is that already-compressed data has little redundancy left. Zipping a folder of JPEGs saves very little, because the JPEGs are already compressed. Zipping a folder of text files or uncompressed images can save a great deal.
Lossy compression
Lossy compression works differently. It permanently removes data that a human is unlikely to notice, smoothing out fine detail in images, for example, or discarding information the eye is poor at perceiving.
JPEG is a lossy format. Each time a JPEG is re-compressed at a lower quality setting, some detail is permanently gone. This is worth stating plainly: the data is not hidden or shelved, it is deleted. Saving a JPEG at 60% quality and then re-saving it at 90% does not restore anything. It just re-encodes the already-degraded image and makes the file larger again.
Repeated re-compression is called generation loss, and it is cumulative. A photo forwarded through several apps, each re-encoding it, degrades measurably even though no single step looked destructive.
The trade-off in practice
The trade-off is always size versus quality. Moderate compression usually produces an acceptable balance. Very aggressive compression, targeting an extremely small file size: can introduce visible artefacts: blurring on text, banding in gradients, pixellation around edges.
Some content types degrade more visibly than others:
- Photographs tolerate compression well. Fine natural detail is exactly what lossy compression is designed to discard quietly.
- Screenshots and text images degrade badly. Sharp high-contrast edges are the hardest thing for lossy compression to preserve, and text goes fuzzy before anything else does. For a screenshot, PNG at full quality is often both smaller and better than a heavily compressed JPEG.
- Gradients and flat colour show banding, smooth transitions break into visible steps.
- Line art and logos belong in a vector format where possible. See best formats for web images.
Quality target versus size target
Image compression on FormatOS offers both a quality setting and a target file size. They behave differently.
A quality setting is predictable: you choose how much detail to keep and accept whatever size results. A size target is iterative: the tool compresses, measures, adjusts and repeats until it lands near the number you asked for. That means the resulting quality depends entirely on how demanding your target is. An ambitious target on a large, detailed image will reach it, but at a quality you may not accept.
If the platform you are uploading to sets a hard size limit, a size target is the right tool. If you simply want a smaller file, a quality setting gives you more control.
There is also a step people skip: resizing before compressing. An image at 4000 pixels wide, compressed hard, often looks worse and weighs more than the same image resized to the dimensions it will actually be displayed at and then compressed gently. Reduce dimensions first, then compress.
Before you compress
Before compressing any file you want to keep, compress a copy rather than the original, and compare the output at full size. What looks acceptable as a small thumbnail can look obviously degraded at full resolution.
Practical note: Start with a moderate quality setting and preview before downloading. Compression cannot be reversed: keep your originals.