Image Compression Explained: Lossy vs. Lossless
Image Tools - 3 min read - Published 2026-09-06 - Updated 2026-10-19
An uncompressed photo is big: a 12-megapixel image stores three color values for each of 12 million pixels, about 36 MB. Image compression is why the same photo is usually a few megabytes on your phone and can be a few hundred kilobytes on a web page. There are two basic approaches, and choosing the right one - plus the right size - makes the difference between crisp, fast images and blurry or bloated ones.
Lossless compression
Lossless compression shrinks a file without discarding any information; decompressing it gives back exactly the original pixels. It works by finding patterns and repetition, such as long runs of the same color, and describing them more compactly.
PNG is the best-known lossless format. It's ideal for screenshots, logos, diagrams, charts and anything with text, sharp edges or flat areas of color, and it supports transparency. It's a poor choice for photos: because photographs have very little exact repetition, a PNG photo is often several times larger than a good JPEG of the same image.
Lossy compression
Lossy compression throws away detail that people are unlikely to notice, which allows much smaller files. JPEG, the standard photo format since the early 1990s, splits the image into 8 × 8 pixel blocks, converts each block into a description of its patterns of light and dark, and rounds away the fine detail. It also stores color at lower resolution than brightness, because our eyes are more sensitive to brightness.
The quality setting controls how much is rounded away. Settings around 75-85 usually look almost identical to the original at a fraction of the size. Much lower, and blocky artifacts appear, especially around sharp edges and text, with a smeared look in smooth areas such as skies.
JPEG damage also accumulates. Each time a JPEG is edited and saved again, it's compressed again, and quality drops a little more. Keep an original and export a fresh copy from it rather than repeatedly re-saving the same file.
WebP and AVIF
Newer formats do better than JPEG and PNG. WebP supports both lossy and lossless compression plus transparency, and Google reports lossy WebP files are typically 25-34% smaller than comparable JPEGs. AVIF, based on the AV1 video codec, often achieves even smaller files at the same visual quality, especially for photos.
All current major browsers display WebP, and AVIF support is now widespread too. For websites, serving WebP or AVIF with a fallback is common practice. For sending a photo to someone who may open it in older software, JPEG is still the safest choice.
Resize first, then compress
The biggest saving usually comes from dimensions, not quality settings. A phone photo might be 4,032 × 3,024 pixels, but a web page might display it 800 pixels wide. Sending the full-size image makes the browser download about 19 times as many pixels as it shows. Resizing to the display size (or twice that, for sharp high-density screens) before compressing often cuts the file to a small fraction of its size with no visible difference.
A simple workflow: resize to the largest size the image will actually be shown, choose the format (photo: JPEG, WebP or AVIF; graphic or screenshot: PNG or lossless WebP), then adjust quality and compare side by side at 100% zoom.
Hidden data in photos
Photos from phones and cameras usually carry EXIF metadata: the camera model, settings, date and time, and often the GPS location where the photo was taken. It adds a little to file size and can reveal more than you intend, such as your home address. Many compressors and social networks strip metadata; if privacy matters, check that it's removed before sharing a photo publicly.