AI & the Internet

How Image Compression Shrinks Photos Without Ruining Them

A photo file can shrink dramatically yet still look fine. Here is how compression throws away detail your eyes barely notice.

Written and reviewed by the Hubrax team · Updated April 17, 2026

Pixelated detail of a digital image
Photograph via Unsplash

You snap a photo on your phone, and the raw image data could be tens of millions of numbers. Yet the file that lands in your messages or loads on a web page is a tiny fraction of that size, and it still looks great. That shrinking is the work of image compression, and it manages to throw away most of the data while keeping a picture that looks essentially the same to you. Here is how it pulls off that trick.

What a digital image really is#

Before compression makes sense, it helps to know what is being compressed. A digital photo is a grid of tiny dots called pixels. Each pixel is just a few numbers describing its color, usually how much red, green, and blue it contains.

A modern photo can hold millions of pixels, and each pixel needs its own color numbers. Stored bluntly, with every pixel written out in full, the file would be huge and slow to send or load. Compression is the set of techniques that records the same picture using far less data.

There are two broad approaches, and the difference between them matters.

Lossless versus lossy: two different deals#

Compression comes in two flavors, and they make different promises.

  • Lossless compression shrinks the file without throwing anything away. You can rebuild the original image perfectly, pixel for pixel. It is like folding a map neatly; nothing is lost, it just takes less space.
  • Lossy compression shrinks the file much more by permanently discarding some detail. You cannot get the original back exactly, but if it is done well, you will not notice what is missing.

Most photos you share online, such as JPEG files, use lossy compression, because it achieves dramatically smaller files. Formats like PNG often use lossless compression, which is better for graphics, logos, and screenshots where every crisp edge matters. The right choice depends on whether perfect fidelity or small size matters more.

The easy wins: removing redundancy#

Both kinds of compression start by hunting for redundancy, meaning information that repeats or is predictable.

Imagine a photo with a large patch of clear blue sky. Thousands of neighboring pixels are nearly the same shade of blue. Instead of storing each one separately, the file can record something closer to "this whole region is this blue." Spelling out every identical pixel would be like writing a grocery list that says "apple, apple, apple, apple" instead of "4 apples."

This idea, recording a pattern once instead of repeating it, is at the core of all compression. Real photos are full of such predictability: smooth gradients, repeated textures, and areas where one pixel strongly hints at its neighbors. Squeezing out that repetition saves a lot of space without losing anything at all.

The clever part: discarding what your eyes ignore#

Lossless tricks only go so far. The big savings in lossy compression come from a deeper insight: human eyes are not equally sensitive to everything in an image, so some detail can be thrown away without you noticing.

Two facts about human vision get exploited:

  1. We are more sensitive to brightness than to color. Our eyes notice changes in light and dark much more than subtle shifts in hue. So lossy compression can store the brightness information in fine detail while recording color more coarsely. You rarely perceive the difference.
  2. We barely notice fine, rapid changes in detail. Smooth areas and broad shapes are what we focus on; tiny, high-frequency variations between adjacent pixels are easy to lose without the picture looking different.

To take advantage of this, JPEG-style compression breaks the image into small blocks and mathematically separates the bold, important patterns in each block from the fine, subtle ones. It then keeps the important patterns and aggressively trims the subtle ones, because that is where your eyes are least likely to object. This is the heart of how a photo can lose most of its data and still look fine.

Why quality is a dial you can turn#

When you save a JPEG, you often get to choose a quality setting. That slider controls how aggressively the compression discards detail.

  • Turn the quality up, and the file keeps more detail but takes more space.
  • Turn it down, and the file shrinks further, but you start losing visible detail.

Push compression too hard and the trade-off becomes obvious. You may see artifacts: blocky squares, smudged edges, or halos around sharp lines. These appear because the compression has thrown away so much that its small blocks can no longer blend together smoothly. The art of good compression is finding the point where the file is small but the artifacts stay invisible.

One important caution: lossy compression is permanent and cumulative. Each time you save a JPEG again, more detail is discarded. Repeatedly opening, editing, and re-saving the same JPEG slowly degrades it, a bit like photocopying a photocopy. For images you plan to edit many times, working in a lossless format and compressing only at the end keeps things crisp.

Where this shows up in daily life#

Compression is quietly everywhere, and it shapes your experience more than you might think.

  • Web pages load faster because images are compressed before being sent to your browser. Smaller files mean less waiting.
  • Messaging apps shrink photos so they send quickly and use less of your data plan, which is also why a picture forwarded many times can look rougher each time.
  • Your phone's storage stretches further because photos are saved in compressed formats rather than raw pixel-by-pixel data.
  • Streaming and video calls rely on the same core ideas, applied to moving images, to fit smoothly through your internet connection.

Common misconceptions#

  • "Compressing an image always wrecks it." Only lossy compression removes detail, and at sensible settings the loss is invisible. Lossless compression removes nothing at all.
  • "A smaller file always means worse quality." Not necessarily. Removing genuine redundancy shrinks the file with no quality cost. Quality only suffers when meaningful detail is discarded.
  • "Re-saving a JPEG is harmless." Each lossy save discards a little more, so repeated saves slowly add up.

The takeaway#

Image compression shrinks photos by removing data you do not need: first the redundant, repeated information, then, in lossy formats, the fine detail your eyes barely register. A quality dial lets you balance file size against how much detail you keep. Understanding the difference between lossless and lossy compression, and that lossy loss is permanent, helps you choose the right format and keep your images looking their best while still loading and sending fast.

Theo Lindqvist
Written by
Theo Lindqvist

A former systems engineer, Theo has built and broken enough hardware and software to explain how it actually works — trade-offs included. He tests his claims on real devices and is allergic to marketing speak. He thinks the best technology is the kind you never have to think about.

More from Theo