Image Compression Basics
How image compression makes files smaller, the difference between lossy and lossless methods, and how to compress without visible damage.
Images are made of millions of pixels, and storing every value directly would make enormous files. Compression finds smarter ways to store the same image, or a very similar one, in less space.
Lossless compression
Lossless compression shrinks a file without changing a single pixel. It finds patterns, such as large areas of the same colour, and describes them efficiently. When the image is opened, it's rebuilt exactly.
PNG and lossless WebP use this. It's ideal for graphics, screenshots, text and cutouts with sharp edges.
Lossy compression
Lossy compression goes further by discarding details the eye is unlikely to notice. It might simplify fine textures or subtle colour variations. The file becomes much smaller, but the image is no longer exactly the original.
JPEG, lossy WebP and AVIF use this. It's ideal for photos.
The quality setting
Lossy formats have a quality setting. Lower quality means smaller files and more visible artefacts:
- Blockiness in smooth areas like skies.
- Ringing or halos around sharp edges and text.
- Colour smearing in fine details.
A quality setting around 75 to 85% is often a good balance for photos on the web. Always check the result.
Compression and editing
Each time you re-save a lossy file, it loses a little more quality. Edit from the original and save the final version once. See why quality drops with repeated saves.
Size first, then compression
The biggest file savings come from using the right pixel dimensions. A 4000-pixel photo shown at 800 pixels wastes most of its data. Resize first, then compress. See reducing an image's file size.
Choosing a format
For a deeper comparison, see lossless vs. lossy and PNG vs. JPEG.