14 categories See all →
home / blog / Images

How Image Compression Actually Works

What that "quality" slider is really doing, why JPGs degrade when you re-save them, and practical tips for smaller files without visible loss.

Most people drag a quality slider down until the file looks "small enough" without really knowing what that slider is doing. It's not scaling the image down. It's not reducing the colours in any way you'd recognise. It's doing something much more specific — and once you know what, you can make much better decisions about when to push it hard and when to leave it alone.

Lossy compression — what JPG is actually doing

JPG compression works by exploiting a quirk of human vision: we're far more sensitive to changes in brightness than to small shifts in colour, and we don't notice high-frequency fine detail nearly as well as we think. The algorithm breaks the image into small blocks, transforms each block mathematically (this is the "DCT" step — discrete cosine transform — you may have seen mentioned), and then more aggressively rounds off ("quantizes") the fine-detail components while preserving the broad brightness and colour information we actually notice.

The "quality" setting controls exactly how aggressively that rounding happens. A high quality setting (90–100%) rounds very gently — you lose almost nothing visible, and the file shrinks modestly. A low setting (10–30%) rounds hard, throwing away a lot of fine texture, and you start seeing it: blotchy "blocky" patches, especially around sharp edges and in areas with fine texture like hair or foliage. That's compression artifacting, and it's the visible evidence of the quality setting being too aggressive for that particular image.

Lossless compression — what PNG is actually doing

PNG doesn't throw away any image data. Instead it uses a deflate-style algorithm — broadly the same family of compression as a ZIP file — that finds repeated patterns and redundancy in the pixel data and encodes them more efficiently, without ever discarding information. That's why decompressing a PNG always gives you back pixel-for-pixel exactly what you started with. It's also why PNG compresses flat-colour graphics (logos, screenshots, text) extremely well — lots of repetition to exploit — but compresses photographs poorly, since natural photos have very little exact repetition for the algorithm to find.

Why re-saving a JPG repeatedly makes it worse

This is the part that trips people up. Every time you open a JPG, edit it, and save it again as a JPG, the compression step runs again — on an image that's already had detail thrown away once. The algorithm doesn't know what was "real" detail versus what was already a compression artifact from last time; it just compresses what it sees now, discarding a bit more. Do this enough times — a photo passed through multiple edits, each time re-exported as JPG — and you get visibly mushy, blotchy results. This is called generation loss.

PNG doesn't have this problem. Because nothing is discarded on save, you can open and re-save a PNG a hundred times and get back the exact same pixels every time. If you're going to be editing an image repeatedly before a final export, work in a lossless format (or your editor's native format) and only convert to JPG once, at the end.

Practical tips that actually move the needle

Resize before you compress. This is the single biggest lever most people ignore. A 4000×3000px photo compressed hard is still a large file, because there's simply more pixel data to encode. Resizing that same photo down to the dimensions it'll actually be displayed at — say 1200×900px for a web page — before compressing typically shrinks the file far more than cranking the quality slider down ever will, and with far less visible quality loss.

70–85% JPG quality is the sweet spot for most web use. Below about 70%, artifacts start becoming noticeable on most photos. Above 85%, you're usually paying significant file size for improvements most people can't actually see on a screen. Print or archival work is the exception — go higher, or use a lossless format.

Our Image Compressor lets you compress to JPEG, WebP, or PNG with a live quality slider and a before/after size comparison, so you can see exactly where the artifacts start appearing for your specific image before you commit. It runs entirely in your browser — your photo is never uploaded anywhere.