Back to all guides
Compression·3 min read·

How Image Compression Works: Lossy vs Lossless

Understand lossy and lossless compression, common image artifacts, and how to compare exports without relying on a universal quality setting.

How Image Compression Works: Lossy vs Lossless

Image compression reduces the bytes needed to store or transmit an image. It does not always reduce pixel dimensions, and it does not always preserve every pixel. Understanding that distinction explains why a flat logo can compress differently from a noisy photograph and why an aggressively compressed image may show blocks, halos, or smeared texture.

Visual explanation of How Image Compression Works: Lossy vs Lossless
Topic-specific visual summary of the concepts and checks in this guide.

Why some images compress more easily

Images contain patterns and redundancy. Large areas of similar color, repeated shapes, and smooth gradients are often easier to encode than sensor noise, fine foliage, hair, or film grain. A photograph with lots of texture may remain relatively large even when the encoder is working correctly. File size is therefore a property of the image, format, encoder, dimensions, and settings together.

  • Flat illustration: often responds well to palette, prediction, and lossless techniques.
  • Photograph: often benefits from perceptual lossy compression.
  • Screenshot with text: sharp edges make visible artifacts easier to notice.

Lossless versus lossy

Lossless compression reconstructs the same pixel values after decoding. PNG is a familiar lossless format; WebP also has a lossless mode. Lossy compression discards information to save more space. JPEG and lossy WebP are common examples. Lossy does not mean unusable: a carefully encoded delivery copy can look very close to the master, but the discarded information cannot be recovered by increasing quality later.

  • Choose lossless for diagrams, UI screenshots, line art, and files that will be edited again.
  • Choose lossy for many web photographs when a visual inspection confirms acceptable quality.
  • Keep a high-quality master and create delivery copies for each destination.

Recognize compression artifacts

Block boundaries can appear in smooth areas; ringing creates light or dark halos near high-contrast edges; banding turns a smooth gradient into visible steps; texture loss makes hair, grass, and fabric look waxy. These artifacts become more obvious after repeated re-encoding or when a small image is enlarged.

  • Inspect text, diagonals, skin, foliage, and gradients at 100%.
  • Compare at normal viewing size as well; pixel peeping alone can overstate practical differences.
  • If artifacts remain visible, raise quality, change format, or reduce dimensions less aggressively.

A repeatable compression workflow

First resize to the largest dimensions actually needed. Then choose a format suited to the content. Export two or three quality candidates rather than assuming a single quality number will work for every image. Compare their visual appearance and byte size, then verify the output in the target browser or application.

A simple experiment you can repeat

Choose one photograph and one screenshot. Export each as PNG, JPEG, and WebP where supported. Record pixel dimensions and byte size, then compare the same crop. You will usually see that the photograph tolerates lossy compression better than the screenshot’s small text and sharp UI edges. The experiment is more useful than memorizing a “best” quality number because it reveals how your own content behaves with your encoder.

  • Keep the source file unchanged between exports.
  • Use the same dimensions and color profile for each comparison.
  • Record both file size and visible defects.

Compression quality values are encoder-specific. A setting of 80 in one tool is not guaranteed to match 80 in another, and it does not imply a fixed file-size reduction.

Further reading: MDN image formats

How Image Compression Works: Lossy vs Lossless — ImageKitTools | ImageKitTools