OnlyFormat

Lossy vs Lossless Compression: What Every Image Workflow Needs to Know

OnlyFormat Editorial Team···8 min read

Every image file on your disk is the result of a trade-off you probably didn't make consciously: the file was either compressed losslessly, meaning every original pixel can be perfectly reconstructed, or lossily, meaning the encoder threw away information it guessed you wouldn't notice. That decision — made by whoever saved the file — determines whether you can safely edit it again, whether it will survive repeated re-saves, and whether it's suitable for archival storage. This guide explains exactly what's happening under the hood.

1. What lossless compression actually is

Lossless compression reduces file size by removing statistical redundancy — patterns in the data that can be described more compactly than stored literally. The defining property: after you decompress a lossless file, you get back the exact original bytes. Not similar, not visually identical — identical.

Most general-purpose compressors use some variant of three techniques. Entropy coding (Huffman coding, arithmetic coding) assigns shorter codes to frequent symbols and longer codes to rare ones. Dictionary compression (LZ77, LZ78, and derivatives like DEFLATE) replaces repeated sequences with back-references to earlier occurrences. Context modelling improves on entropy coding by conditioning probabilities on recent context — if you've seen a lot of capital letters recently, the next character is probably another capital letter.

Image-specific lossless compressors add prediction filters on top. Instead of compressing the raw pixel values, PNG predicts each pixel from its neighbours (using filters like Sub, Up, Average, Paeth) and compresses the difference. The differences are smaller and more compressible than the original pixel values, so the resulting file is smaller — but no information is lost.

2. What lossy compression actually discards

Lossy compression starts from an insight about human perception: we're much more sensitive to some kinds of information than others. Our eyes have far more receptors for brightness (luminance) than for colour (chrominance). We're good at detecting sharp edges but poor at detecting subtle changes in flat colour regions. And we essentially cannot perceive very high-frequency variation — the kind of noise a sensor picks up or the exact per-pixel structure of a complex texture.

Lossy image codecs exploit this by doing three things. First, they convert from RGB to a luminance/chrominance colour space (like YCbCr) and downsample the chroma channels — typically to half resolution in each dimension. Second, they transform blocks of pixels into frequency components using a discrete cosine transform (JPEG, classic WebP) or a similar wavelet or predictive method. Third, they quantize those frequency components, aggressively rounding the high-frequency ones to zero where the eye won't notice.

The "quality" slider on a JPEG export corresponds roughly to how aggressive the quantization is. Quality 100 keeps almost all frequency information (though JPEG is always lossy in practice because of the colour space conversion); quality 50 discards a lot of it, producing the blockiness and colour bleed that we recognise as "JPEG artifacts."

3. Generational loss: the hidden cost of lossy

Because lossy compression throws away information, re-encoding a lossy file introduces new artifacts on top of the existing ones. The encoder doesn't know which detail in the current decoded image was real and which was an artifact from the previous encoding pass — it just quantizes the frequency coefficients again, losing more information.

On a photograph, a single round of visually-lossless JPEG (quality 90+) is genuinely imperceptible. Five rounds of quality 75 start to show soft edges and colour shifts. Ten rounds at quality 50 produce visibly garbled output. This matters enormously in any workflow where images are edited and re-saved: every save is a one-way transaction that can never be undone.

The rule that follows: keep the original, edit from the highest-quality source, and only emit lossy at the final delivery step. If you shoot RAW, keep the RAW. If a client sends you a JPEG, ask for the original source if one exists. If you're doing multi-stage compositing work, keep your intermediate layers in lossless formats (PNG, TIFF, or a project-file format like PSD).

4. When lossless is the right choice

  • Original captures. Photographs you may edit later, medical imagery, scientific data.
  • Source assets. Logos, icons, UI elements, typography — anything you'll composite into other work.
  • Images with sharp edges and flat colour. Lossy compression produces visible ringing artifacts around text and high-contrast edges; lossless avoids this entirely.
  • Archival. A lossless copy of a document is a faithful record. A lossy copy is an approximation whose accuracy depends on settings you may not remember in ten years.
  • Images that will be edited iteratively. Every round of lossy encoding accumulates damage.

5. When lossy is the right choice

  • Final delivery for photographic web content. A lossy WebP or AVIF file delivered to a browser is 3–10× smaller than the lossless equivalent, and no viewer will be able to tell at sensible quality settings.
  • Bulk thumbnails and previews. Thousands of small thumbnails add up to gigabytes; lossy compression makes that tractable.
  • Final-render video, which is fundamentally lossy for the same bandwidth reasons.
  • Attachments bound by size limits. Email, SMS, and upload forms often cap at 5–25 MB. Getting under the limit usually requires lossy compression.

6. Format-by-format cheat sheet

FormatLossy modeLossless modeDefault in most tools
JPEGYesRare (not widely supported)Lossy
PNGNoYesLossless
WebPYesYesDepends on tool
AVIFYesYesLossy
HEICYesYes (rare)Lossy
TIFFPossible (with JPEG inside)Yes (LZW, ZIP, uncompressed)Lossless

Need to compress or convert an image?

OnlyFormat's image compressor lets you control quality directly. All processing happens in your browser — your files never leave your device.

Frequently asked questions

Q. Is JPEG lossy or lossless?

A. JPEG is lossy by default. There is a 'lossless JPEG' mode defined in the original 1992 standard, but almost no tool supports it and you can safely assume any JPEG you encounter is lossy. JPEG's successor, JPEG 2000, supports both modes, as do WebP and AVIF.

Q. Does saving a lossy file as lossless recover the quality?

A. No. Once information is discarded by lossy compression, it's gone. Converting a JPEG to PNG at the same dimensions preserves the current decoded quality but does not recover the detail lost during the original JPEG compression. This is why you should always edit from the highest-quality source you have.

Q. What is generational loss?

A. The gradual quality degradation that happens when you repeatedly decode and re-encode a lossy file. Each save introduces new compression artifacts on top of the previous ones. After 5–10 rounds of JPEG re-saving, even a photograph that started sharp and clean shows blocky artifacts and colour shifts.

Q. Can lossless formats have smaller files than lossy ones?

A. On photographic content, almost never — lossy compression has an order-of-magnitude advantage on photos. On flat graphics (logos, UI, screenshots), lossless formats like PNG and WebP-lossless can actually beat lossy JPEG both on quality AND file size, because the content compresses extremely well when predicted correctly.

Q. What's 'visually lossless'?

A. A lossy encoding quality high enough that no viewer can tell the difference from the original under normal viewing conditions. For JPEG, quality 90–95 is typically visually lossless on photographs. For WebP and AVIF, quality 85–90 is the equivalent range. Visually lossless files are still lossy — they're just tuned to discard only imperceptible information.

References

  • ISO/IEC 10918-1 — JPEG
  • W3C Recommendation — Portable Network Graphics (PNG) Specification
  • Google WebP Compression Techniques documentation
  • MDN Web Docs — Image file types
  • Khalid Sayood — Introduction to Data Compression (textbook reference for entropy / dictionary / transform coding)

About the OnlyFormat Editorial Team

OnlyFormat's editorial team is made up of working web developers and image-workflow engineers who ship file-conversion tooling for a living. Every guide is reviewed against primary sources — W3C/WHATWG specifications, IETF RFCs, MDN Web Docs, ISO/IEC media standards, and the official documentation of libraries we actually use in production (libwebp, libjpeg-turbo, libavif, FFmpeg, pdf-lib). We update articles when standards change so the guidance stays current.

Sources we cite: W3C · WHATWG · MDN Web Docs · IETF RFCs · ISO/IEC · libwebp · libavif · FFmpeg · pdf-lib