Image Compression Explained: Lossy vs Lossless and the Best Quality Settings
Every image on the web is compressed in some way. An uncompressed 1920 × 1080 photo would be about 6 MB (1920 × 1080 pixels × 3 bytes per pixel). A well-compressed version of the same photo can be 150 KB and look identical at normal viewing size. Knowing how compression works helps you pick settings that cut file size dramatically without visible damage.
Two kinds of compression
Lossless compression shrinks the file without changing a single pixel. Decompress it and you get exactly the original image back. It works by finding patterns and repetition, much like a ZIP file. PNG, GIF and lossless WebP use lossless compression.
Lossy compression throws away information that people are unlikely to notice, then compresses what remains. The decoded image is close to the original but not identical. JPEG, lossy WebP and AVIF are lossy formats, and they can make photos 5–20 times smaller than lossless formats.
| Lossless | Lossy | |
|---|---|---|
| Pixels after decoding | Identical | Approximation |
| Typical photo savings | Modest | Very large |
| Re-saving repeatedly | No degradation | Quality drops each time (“generation loss”) |
| Best for | Screenshots, logos, text, line art, editing masters | Photographs, complex images |
| Formats | PNG, GIF, lossless WebP, lossless AVIF | JPEG, WebP, AVIF |
How lossy compression decides what to throw away
JPEG, the format that defined web photography since 1992, uses several tricks based on how human vision works:
- Color subsampling. Our eyes are more sensitive to changes in brightness than in color. JPEG usually stores color at half resolution in each direction (4:2:0), cutting the color data by 75% with little visible effect on photos.
- Frequency transformation. The image is split into 8×8 pixel blocks, and each block is described as a combination of smooth and detailed patterns (the discrete cosine transform).
- Quantization. Fine detail patterns, which the eye notices least, are stored with less precision or dropped. This is what the quality slider controls. Lower quality means coarser quantization and more detail thrown away.
- Entropy coding. The remaining data is packed efficiently, losslessly.
WebP and AVIF use more advanced techniques, including predicting blocks from their neighbours and variable block sizes, which is why they compress better at the same visible quality.
What the quality number means
The quality setting (usually 0–100) is not a percentage of quality. It maps to the quantization tables the encoder uses, and different software maps the numbers differently: quality 80 in one program isn’t identical to quality 80 in another. Still, some patterns hold for photos:
| Quality | Typical result | Use |
|---|---|---|
| 90–100 | Visually lossless, large files | Print masters, archives (better: keep the original) |
| 75–85 | Excellent; differences hard to see at normal size | Most web photos |
| 60–75 | Good for photos with lots of texture; slight softening | Thumbnails, backgrounds |
| Below 60 | Visible blockiness, smudged edges, color bands | Rarely worth it |
The jump from quality 100 to 85 often halves the file size with no visible change. The jump from 75 to 50 saves less and starts to look bad. The image compressor above defaults to 75% WebP, a good balance for most photos.
Artifacts to look out for
- Blocking: visible 8×8 squares in smooth areas like sky.
- Ringing (mosquito noise): fuzzy halos around sharp edges and text.
- Color bleeding: colors smearing past edges, from subsampling.
- Banding: smooth gradients turning into visible steps.
Always check compressed images at 100% zoom, not shrunk to fit your screen, which hides artifacts.
Why screenshots should be lossless
Screenshots, diagrams, logos and anything with text have sharp edges and large flat areas of color. Lossy compression handles these badly: edges get ringing artifacts, and text looks smudgy. Lossless PNG or lossless WebP is usually smaller and sharper for this kind of content. Photos are the opposite: PNG versions can be 5–10 times larger than a good JPEG.
Resize before you compress
Compression works on the pixels you give it. A 4000-pixel-wide photo compressed hard still contains 12 million pixels. Resizing it to its display size first (for example 1600 pixels) removes most of the data before compression even starts. Our guide to resizing images for the web explains how to choose dimensions.
Format matters too
At the same visual quality, typical sizes for a photo are roughly:
| Format | Relative size |
|---|---|
| JPEG (quality ~80) | 100% |
| WebP (quality ~75) | ~65–75% |
| AVIF (quality ~50–60) | ~45–60% |
These are rough figures; results vary by image. We compare the formats in detail in JPG vs PNG vs WebP vs AVIF.
A test with three 12-megapixel photos
To see what the quality slider does in practice, we took three photos at 4032 × 3024, the size a 12-megapixel phone camera produces, and re-encoded each one with Chrome’s built-in encoders, the same ones the compressor above uses: a fjord landscape (photo 1), a dog wrapped in a blanket against a blurred background (photo 2), and a pine forest below granite cliffs (photo 3). The originals were already-compressed JPEGs of 1.63 MB, 1.88 MB and 2.37 MB.
| Setting (full 4032 × 3024) | Photo 1 | Photo 2 | Photo 3 |
|---|---|---|---|
| Original JPEG | 1.63 MB | 1.88 MB | 2.37 MB |
| JPEG quality 90 | 2.10 MB | 2.41 MB | 3.05 MB |
| JPEG quality 75 | 1.71 MB | 1.95 MB | 2.48 MB |
| WebP quality 75 | 1.20 MB | 1.54 MB | 1.99 MB |
| WebP quality 60 | 1.01 MB | 1.22 MB | 1.68 MB |
| WebP quality 40 | 792 KB | 864 KB | 1.30 MB |
Two things stood out. First, re-saving at JPEG 90 made every file bigger than the original, by about 30%. The originals had already thrown detail away, and a high quality setting spends bytes faithfully preserving the compression noise. Quality numbers also aren’t comparable between tools: “90” in one encoder is not “90” in another.
Second, at full resolution even WebP 60 only took about a third off. The large savings came from changing the pixel dimensions, not the quality setting. The same three photos resized to 1600px wide and saved as WebP 75 came out at 239 KB, 173 KB and 384 KB, between 84% and 91% smaller than the originals. That is why the compressor has a maximum width option, and why it is worth using.
Avoid generation loss
Each time you open a lossy image, edit it and save it again as lossy, it loses a bit more quality. Keep a lossless or original master, do all edits on that, and export a compressed copy only at the end.
Metadata is part of the file size
Photos from phones and cameras carry EXIF metadata: camera model, date, settings and often GPS coordinates. It can add tens of kilobytes, and it can reveal where a photo was taken. Re-encoding through a canvas, as browser-based compressors do, drops this data. If you only want to remove metadata without re-compressing, see our EXIF and privacy guide.
A sensible workflow
- Keep the original file.
- Crop and resize to the largest display size (× 2 for high-density screens).
- Choose a format: WebP or AVIF for photos on websites, PNG or lossless WebP for screenshots and graphics.
- Compress at around 75–80 for photos and compare against the original at 100% zoom.
- Check the result loads quickly on a real phone connection.