TSToolSphere
Back to all articles
image

Image Compression: Lossy vs Lossless client-side algorithms

2026-07-217 min read

Try it: free Image Format Converter

Convert images between PNG, JPEG, WebP, and GIF formats client-side.

Open →

Lossy compression: discarding what the eye won't miss

Lossy image compression (JPEG, lossy WebP) works by identifying information the human visual system is less sensitive to and discarding it deliberately. JPEG's specific technique — transforming blocks of pixels into frequency-domain data (via DCT) and quantizing high-frequency components more aggressively — exploits the fact that human vision notices broad color/brightness changes more readily than fine, high-frequency detail. The "quality" slider directly controls how aggressively that quantization discards information: higher quality keeps more of the original frequency detail, at a larger file size.

Lossless compression: finding redundancy, keeping everything

Lossless compression (PNG, lossless WebP, GIF) never discards actual image information — it exploits statistical redundancy in the pixel data instead. Two major techniques combine in most lossless formats:

  • Predictive filtering: instead of storing each pixel's raw value, store the difference from a predicted value (often based on neighboring pixels) — differences tend to be smaller numbers, which compress better with the entropy coding step that follows.
  • Entropy coding (deflate in PNG, more advanced schemes in WebP lossless): assigns shorter codes to more frequent byte patterns and longer codes to rare ones, exploiting the fact that real image data isn't uniformly random.

Neither technique discards anything — decompression always reconstructs the exact original pixel values, which is why lossless formats have no "quality" setting, only an "effort" setting trading encode time for how thoroughly the algorithm searches for redundancy.

Color palette reduction: a separate lever, not compression itself

A distinct technique — reducing the number of unique colors in an image (down to, say, 256 colors, as GIF and indexed PNG do) — isn't compression per se, but it dramatically helps compression afterward, since fewer unique values means more redundancy for the entropy coder to exploit. This works well for graphics with naturally limited color palettes (simple illustrations, icons) and poorly for photographs, where reducing colors introduces visible banding.

Matching the technique to the content

Content Best-suited approach
Photographs, continuous tone Lossy (JPEG, lossy WebP) — quantization loss is imperceptible at reasonable quality
Screenshots, UI, flat-color graphics Lossless (PNG, lossless WebP) — no artifacts on sharp edges
Simple graphics with few distinct colors Lossless + palette reduction (indexed PNG, GIF) — smallest possible size with zero visible loss
Icons, logos, scalable illustrations Vector (SVG) — sidesteps pixel-based compression entirely

Common mistakes

  • Applying lossy compression uniformly regardless of content type. A photo and a screenshot need fundamentally different approaches — a single "just use JPEG" or "just use PNG" rule ignores this.
  • Assuming higher "effort" settings on lossless formats change the output pixels. They don't — only encoding time and how thoroughly redundancy is searched for; the decompressed result is identical regardless of effort level.
  • Not considering palette reduction for simple graphics. For images with genuinely few distinct colors, this can meaningfully shrink file size with zero visible quality loss — a separate, complementary lever to whichever base compression format is used.

FAQ

Does lossy compression always mean visible quality loss?
Not necessarily — at high quality settings on suitable content (photographs), the discarded information is genuinely imperceptible to most viewers; visible artifacts appear specifically when quality is pushed too low for the content's detail level.

Why doesn't lossless compression have a "quality" setting?
Because nothing is being discarded — only the effort spent searching for redundancy varies, and that never changes the final decompressed pixel values.

Is reducing an image's color palette the same as compression?
It's a separate, complementary technique — it doesn't compress data by itself, but it creates more redundancy for a subsequent compression step (like PNG's deflate) to exploit more effectively.

Compress and convert images with both lossy and lossless options using the Image Converter — entirely in your browser.

Looking for other tools?

Explore ToolSphere Homepage →