How image compression actually works
8 min read · Technical
The problem compression solves
A single 12-megapixel photograph contains about 36 million bytes of raw colour data. Storing that without any compression would produce a 36MB file for every photo you take. That is impractical for cameras, phones, websites and email. Compression exists to reduce that number dramatically — often by 95% or more — while keeping the image recognisable.
There are two broad approaches: lossless compression, which reduces file size without discarding any information, and lossy compression, which discards information the human eye is unlikely to notice.
Lossless compression
Lossless algorithms look for redundancy in the data. If a row of 500 pixels is identical, why store 500 separate colour values? Lossless compression stores "500 of the same colour" as a compact instruction instead. When the file is decoded, the original pixels are restored exactly.
PNG uses lossless compression. So does GIF, and so does the lossless mode of WebP. These formats are ideal when the image will be edited further, when it contains text and hard edges, or when perfect fidelity matters.
The limitation of lossless compression is that it cannot achieve the dramatic file size reductions that lossy compression can. A photographic PNG is often 5-10x larger than the equivalent JPG.
Lossy compression
Lossy compression accepts that some information will be permanently discarded in exchange for a much smaller file. The trick is deciding what to discard. Human vision is far more sensitive to brightness than to colour, and far more sensitive to large shapes than to fine detail.
JPG divides the image into 8×8 pixel blocks, transforms each block into the frequency domain, and quantises the result. High-frequency detail — fine texture, sharp edges — is discarded more aggressively than low-frequency detail. The quality setting controls how aggressively this happens.
At quality 90, most people cannot tell the compressed image from the original. At quality 70, artefacts begin to appear around sharp edges. Below quality 50, blocky patches and colour banding become visible in smooth areas like skies.
What WebP does differently
WebP is a modern format that combines techniques from both lossy and lossless compression. It uses a more sophisticated prediction model than JPG, which means it can achieve the same visual quality at a smaller file size. In practice, WebP files are typically 25-35% smaller than JPG at the same visual quality.
WebP also supports transparency and animation, features that JPG lacks. It is supported by all modern browsers, though some older software and forms still require JPG or PNG.
Why dimensions matter more than quality
File size scales with pixel count. A 4000×3000 photo contains twelve million pixels. A 1200×900 photo contains about one million — roughly 8% of the pixels. At the same compression quality, the smaller image will be roughly 8% of the file size.
This is why resizing is often more effective than aggressive compression. A 4000px photo compressed to 100KB will show visible artefacts. The same photo resized to 1200px and lightly compressed will look sharp at any reasonable display size.
How FITLY applies this
FITLY works from a target size backwards. It decodes your image, re-encodes it at a trial quality, measures the resulting file, and estimates what change is needed. If quality alone cannot reach the target, it reduces dimensions in small steps. This produces a result that is as sharp as possible for the requested file size.
Everything runs locally in your browser. Your image is never uploaded to a server.
Try it now
Compress an image to a specific target size using the FITLY tool — free, no signup, and completely private.