Irreva logo
Explore Irreva
ImageJanuary 22, 2026· 8 min read· Updated June 10, 2026

How Image Compression Works — The Plain English Version

Hasanur Rahman

Written by Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Image compression is one of those things most people use constantly without thinking about how it works. You drag a photo into a compressor, a smaller file comes out, and it looks roughly the same. What actually happened in those few milliseconds? This guide explains the mechanics clearly — no maths degree required.

What compression actually means

A digital image is fundamentally a grid of pixels. Each pixel has a color value — typically stored as three numbers representing the red, green, and blue channels. An uncompressed 12-megapixel photo stores 12 million pixels, each with three 8-bit color values, totalling around 36MB of raw data.

Compression algorithms look for patterns and redundancies in that data and encode them more efficiently. A sky that's mostly the same shade of blue doesn't need to store that value 400,000 times. Instead, it can say 'repeat this color across this region' and store it once.

How aggressively an algorithm exploits these patterns — and whether it discards information to do so — is what separates the different compression types.

Lossy compression — trading quality for size

JPG (or JPEG) is the most common lossy format. It compresses images by grouping pixels into 8×8 blocks and applying a mathematical transformation called Discrete Cosine Transform (DCT) to each block. The algorithm then discards fine detail that human vision is least sensitive to, particularly in areas of high-frequency texture.

The 'quality' setting in a JPG compressor controls how much detail is discarded. At quality 100, almost nothing is thrown away and file sizes stay large. At quality 60, significant detail is removed but the image often looks acceptable to most viewers. The sweet spot for web images is usually 75–85%.

Once data is discarded in a lossy format, it's gone permanently. Re-editing and re-saving a JPG in a photo editor compounds this quality loss each time. Always work from the original if you need to make edits.

Lossless compression — smaller files, no quality cost

PNG uses lossless compression. Every pixel value is preserved exactly. The algorithm finds patterns in the data (like runs of identical colors) and encodes them more efficiently, but nothing is thrown away.

Lossless compression produces larger files than lossy for photographs, but it's ideal for anything with sharp edges, flat colors, or text — like screenshots, logos, and diagrams. JPG compression on these creates visible blocky artifacts (called ringing or mosquito noise) around high-contrast edges.

WebP supports both lossy and lossless modes. The lossless WebP format typically produces files 20–30% smaller than equivalent PNG files.

Why WebP is worth switching to

Google developed WebP specifically to be a better format for the web. Its lossy mode is based on VP8 video compression and produces files roughly 25–35% smaller than JPG at the same visual quality. Its lossless mode beats PNG by a similar margin.

WebP also supports transparency (like PNG) and animation (like GIF but with better compression). In 2026, browser support is essentially universal — all major browsers on all platforms support it.

The practical implication: if you're preparing images for a website, converting your JPGs to WebP will typically shave 25–35% off your total image payload with no visible quality difference.

What 'quality' settings actually do in practice

The quality slider in a compressor isn't a percentage of the original quality. It's a control over how aggressively the compression algorithm discards information. Different compressors implement this scale differently, so quality 80 in one tool isn't exactly equivalent to quality 80 in another.

As a practical guide: 85–95 is very high quality with modest compression. 70–85 is the standard range for web use — files are small and the quality difference is barely noticeable. Below 60 you'll start seeing obvious artifacts in most photos. For thumbnails and background images, 50–65 is fine.

The most useful thing to do is look at the actual output rather than rely on numbers. Use the before/after preview in the compressor to find the lowest quality setting where the image still looks acceptable for your use case.

Frequently Asked Questions

Does compressing an image damage it permanently?

For lossy formats like JPG, yes — the discarded detail is gone. You should always keep your original file. For lossless formats like PNG, compression is reversible; decompressing gives you back the exact original data.

Can I compress an image multiple times?

You can, but each time you re-save a JPG you add another round of lossy compression. Quality degrades cumulatively. For repeated edits, work in a lossless format like PNG and only convert to JPG at the end.

What's the best format for web images?

WebP is the best default for most web images in 2026 — it's smaller than both JPG and PNG at the same quality, supports transparency, and has universal browser support. Use JPG as a fallback for contexts where WebP isn't supported.

How much can I compress an image without it looking bad?

It depends on the image content. Photographs with smooth gradients tolerate high compression well. Images with text, logos, or fine line detail are more sensitive. As a starting point, try 80% quality and check the result at the actual size it will be displayed.

Does resizing an image help with file size?

Yes, significantly. File size scales roughly with the number of pixels. A 4000×3000 photo has 12 million pixels. Halving both dimensions gives you 2000×1500 with only 3 million pixels — a 75% reduction in pixels before any compression is applied. Resize to the largest size you'll actually display the image at.

Hasanur Rahman

About the author

Hasanur Rahman

Founder & Full-Stack Developer · Irreva · Rangpur, Bangladesh

Hasanur Rahman is the founder of Irreva and a full-stack developer based in Rangpur, Bangladesh. He builds all of Irreva's tools with a focus on privacy-first, browser-based processing.