Lossy vs lossless compression

Lossless compression shrinks a file in a way that can be undone exactly: the decoded image is identical to the original, pixel for pixel. Lossy compression throws away detail it judges you will hardly notice, so the file gets much smaller but can never be restored exactly.

Use lossy (JPG, lossy WebP) for photos you are about to share or publish. Use lossless (PNG, lossless WebP) for logos, screenshots, text, line art, and any master copy you will edit again.

How lossless compression works

A lossless encoder looks for patterns it can write down more briefly, such as runs of the same colour or rows that repeat the row above, and stores those instead of every value. The W3C's PNG specification defines lossless as a method that “permits reconstruction of the original data exactly, bit-for-bit”. PNG first applies a filter that the specification calls “deterministic, reversible, and lossless”, then compresses the result with deflate.

This works brilliantly on flat colour and sharp edges, and badly on photos. A photo's fine grain and noise are information too, and a lossless format has to keep all of it.

How lossy compression works

A lossy encoder stores an approximation of the picture instead of its exact pixels. MDN describes JPEG's compression as “Lossy; based on the discrete cosine transform”, and explains why photos cope with it: their discarded detail “is harder to see”. The quality setting decides how rough the approximation is allowed to be.

The size falls fast at first and then flattens out, while the damage grows. It shows first where the picture is hardest to approximate: MDN mentions “blurring and colored fringes around text and sharp edges”, and warns that applying lossy compression “to content requiring sharpness, like diagrams or charts, can produce unsatisfactory results.”

The in-between case: fewer colours, saved losslessly

PNG has an indexed-colour mode: up to 256 palette entries, with every pixel storing the number of its palette colour. Reducing an image to a palette is a lossy step, because similar colours are merged. Saving the result as PNG is lossless. For graphics with few colours, this pair often beats both plain PNG and JPG.

This is what the PNG compressor does by default. Its Lossless only option skips the palette step and keeps every pixel exactly.

Which formats use which

FormatCompressionTransparency
JPG (JPEG)LossyNo: one or three colour components, no alpha
PNGLossless, optionally with a palette of up to 256 coloursYes, optional alpha channel
WebPEither lossy or losslessYes, in both modes

Google's WebP page reports that lossless WebP files are 26% smaller than PNGs and lossy WebP files 25–34% smaller than comparable JPEGs, which is why WebP is a good choice for both kinds of image on the web where it is accepted. For a direct format comparison, see PNG vs JPG.

Choosing between them

The compressor uses lossy JPG or WebP for photos and a colour palette for PNGs that need to keep transparency, searching for the highest quality that fits the size you set. If your aim is the smallest file with the least visible change, the guide onreducing image size without losing quality goes further.

Questions

Is PNG always lossless?

The PNG format is. But a tool can change the pixels before saving, for example by reducing a picture to 256 colours, and then save that result losslessly. The file is a valid PNG; the colour reduction was the lossy part.

Does converting a JPG to PNG make it lossless?

It makes any later saves lossless, which helps if you will edit the picture many times. It does not bring back detail the JPG already discarded, and the file gets much bigger.

Sources

  1. Portable Network Graphics (PNG) Specification (Third Edition), W3C. Checked December 2026.
  2. JPEG File Interchange Format, version 1.02, hosted by W3C. Checked December 2026.
  3. An image format for the Web (WebP), Google for Developers. Checked December 2026.
  4. Image file type and format guide, MDN Web Docs. Checked December 2026.

Browse all image guides