What Actually Happens When You Compress an Image?

October 6, 2026 6 min read Image Formats

When you compress an image and the file gets smaller, that data has to go somewhere — and it doesn't go to some other file. It's gone. The question is whether you notice, and more importantly, whether you can get it back. The short answer is no. But understanding exactly what gets thrown away, and why, changes how you think about every image you edit, export, or send.

Two Completely Different Things Called "Compression"

The word "compression" covers two very different processes that work in opposite ways:

Lossless compression finds redundant patterns in a file and encodes them more efficiently. No information is discarded. You can decompress the file and get back the exact original, bit for bit. PNG uses lossless compression. ZIP files use lossless compression. The downside is that the file size reduction is limited — you can only squeeze out so much by rearranging patterns.

Lossy compression actually throws away information. It exploits the limits of human perception — discarding visual details the eye supposedly won't notice — to get much smaller files. JPEG uses lossy compression. So do MP3 for audio and MP4 for video. The reduction in file size can be dramatic, but it's permanent. Once information is discarded, it cannot be reconstructed.

The key distinction: Compress a PNG and decompress it — you get the original back exactly. Compress a JPEG at quality 60, then export it again at quality 100 — you don't get the original back. You get a large file of a degraded image.

How JPEG Compression Actually Works

JPEG is the format most people mean when they talk about "compressing" a photo. What it does is genuinely clever — and genuinely destructive.

1
Color space conversion
The image is converted from RGB (red, green, blue) to a format that separates brightness from color. Human eyes are much more sensitive to brightness variations than color variations, so JPEG exploits this by preserving brightness precisely and approximating color more aggressively.
2
Block division
The image is divided into 8×8 pixel blocks. Each block is processed independently. This is why heavily compressed JPEGs show visible "blocking" artifacts — you're literally seeing the edges of those 8×8 squares when the compression is too aggressive.
3
Frequency analysis (DCT)
Each block is analyzed using a Discrete Cosine Transform, which describes the block as a combination of frequency patterns — broad gradients at low frequency, fine detail at high frequency. This converts spatial pixel data into frequency data that's easier to selectively discard.
4
Quantization — where quality is lost
The frequency values are divided by a quantization table, then rounded to integers. High-frequency values (fine detail) are divided by large numbers, making them round to zero — effectively deleting them. The quality setting controls how aggressively this rounding happens. This step is irreversible.

The final step is lossless encoding of the surviving data. The lossy damage was done in step 4 — the rest is just packing what's left efficiently. When you open the JPEG, the decoder reads it back, but those zeroed-out frequency values are gone. The decoder reconstructs the image from what remains, filling in the missing detail with approximations.

What "Quality 80" Actually Means

Most image editors give you a quality slider from 0 to 100 when saving a JPEG. What you're really controlling is how aggressively the quantization table rounds values in step 4.

At quality 100, the quantization divisors are all 1 — meaning no rounding occurs, and the DCT values are preserved exactly. The file is still technically lossy (the color space conversion in step 1 discards some information), but the visible quality is essentially perfect.

At quality 60, fine detail and high-frequency patterns are heavily rounded or zeroed out. The file is much smaller, but smooth gradients may show banding, edges may soften, and textured areas may look smudgy.

At quality 20 or below, blocking artifacts become visible, colors posterize, and the image starts to look like it was viewed through frosted glass.

Re-saving is cumulative damage: Every time you open a JPEG and save it again as a JPEG — even at quality 100 — the quantization step runs again on the already-degraded data. Three or four re-saves at quality 80 produces noticeably worse results than one save at quality 80. Always keep an original copy and export from that.

Lossless Compression: What PNG Does Instead

PNG uses a completely different approach. Rather than discarding information, it looks for patterns it can describe more efficiently. A row of 500 identical blue pixels doesn't need to be stored as 500 separate values — it can be stored as "blue, ×500." PNG uses a filter step to make rows of pixels more predictable (turning absolute values into differences from neighboring pixels, which are smaller numbers), then applies DEFLATE lossless compression on the result.

The result is a file that can be perfectly reconstructed every time. For images with large flat areas, solid colors, text, or line art, PNG compression is very effective. For photographs with millions of subtly different colors, PNG compresses much less than JPEG — photographs don't have the repetitive patterns that lossless compression exploits well.

Choosing the Right Compression for the Job

Use caseBest formatWhy
Photographs for webJPEG or WebPLossy compression achieves very small files with barely visible quality loss at moderate settings
Screenshots, UI, textPNGLossless preserves sharp edges and exact colors; lossy would blur text and create artifacts around edges
Logos, icons, illustrationsPNG or SVGFlat colors and sharp lines need lossless; SVG is even better for vector graphics
Photos for archivingPNG or TIFFKeep a lossless original; you can always export a compressed version later
Photos for sharing or emailJPEG (quality 80–90)Good balance of file size and visible quality for casual viewing
Photos for web (modern)WebPSmaller than JPEG at equivalent quality; supported by all modern browsers

Why You Can't "Restore" a Compressed Image

This comes up often — someone compresses an image, notices quality loss, and wonders if there's a tool to fix it. There isn't, not really. The information that was discarded during quantization is simply gone. No software can reconstruct detail that was never stored.

What AI upscalers and enhancement tools do is hallucinate plausible detail based on patterns learned from other images. They can make a compressed image look sharper and cleaner, but the "detail" they add is invented, not recovered. Whether that's useful depends on the purpose — it might look fine for a social media post but be completely wrong for a document scan.

The only real fix is to start from a higher-quality original. This is why keeping your originals — the uncompressed or minimally compressed versions straight from the camera — matters so much. You can always compress down from a high-quality original. You cannot compress up from a low-quality one.

Compress Images — Free, In Your Browser

Adjust quality and see file size in real time. Convert to WebP for even smaller files. Nothing is uploaded — everything runs locally.

Open Image Compressor