Every digital image you see online has been compressed. The photo on the news article you just read, the product image you zoomed in on, the avatar in someone's comment — all compressed. Compression is what makes it economically and technically feasible to serve billions of images across the web every day. Understanding how it works helps you make better decisions about file formats, quality settings, and when compression artefacts are acceptable versus damaging.
An uncompressed image stores every pixel as a fixed number of bits — typically 24 bits (8 bits per colour channel for red, green, and blue). A 1920×1080 photograph at 24 bits per pixel contains roughly 6.2 million pixels, which works out to approximately 186 million bits, or about 22 MB. That's the raw, uncompressed data that lives in memory when an image is open on your screen.
Image compression is the process of reducing that 22 MB down to something practical for storage and transmission — typically 200 KB to 2 MB for a web photograph — by encoding the pixel data more cleverly. There are two fundamentally different approaches: lossy compression, which achieves smaller sizes by permanently discarding some image data, and lossless compression, which reduces file size without discarding any information at all.
Understanding the difference between these two approaches — and knowing which formats use which — is the foundation of making good decisions about image quality and file size for any project.
Lossy compression works by exploiting weaknesses and biases in human visual perception. The idea is that the eye and brain do not perceive all visual information equally — we are far more sensitive to changes in brightness than to changes in colour, we are more sensitive to broad gradients than to fine high-frequency detail, and we are better at detecting changes in large uniform areas than at detecting subtle texture variations in complex scenes.
JPG — the most widely used lossy format — uses a technique called DCT (Discrete Cosine Transform). The image is divided into 8×8 pixel blocks. Each block is transformed from pixel values into a mathematical representation of its frequency content — essentially, how much the block contains of large-scale gradients versus fine detail. High-frequency components (fine detail) are then quantised more aggressively than low-frequency components (broad gradients), because the human eye is less sensitive to high-frequency variations. The quality setting controls how aggressively this quantisation is applied.
Here is what a 5 MB RAW photograph becomes at various JPG quality settings:
The key characteristic of lossy compression is that it is irreversible. Once you save a JPG at quality 80, the data that was discarded is gone forever. If you later save that same file again at quality 80, you're compressing an already-degraded image — the quality loss compounds, and the result is worse than the original quality-80 save. This is why you should always keep the original high-quality source file and only export the compressed version for use.
Lossless compression reduces file size without discarding any image data whatsoever. The output is mathematically identical to the input — decode a losslessly compressed image a thousand times, and you get the exact same pixel values every single time. There are no artefacts, no quality degradation, no trade-offs in visual fidelity.
Lossless algorithms work by finding and exploiting redundancies in the data itself. Several techniques are commonly used:
The trade-off is that lossless compression has a ceiling. Natural photographs contain enormous amounts of apparent randomness — variations in colour, texture, and detail at every scale — that don't compress well under lossless algorithms. A photographic PNG is often 3–5× larger than the equivalent quality-85 JPG. This is why PNG is not the right choice for photographs on the web, and why JPG exists at all.
Lossless compression is ideal for images that do have large areas of identical or predictable data: logos, icons, illustrations, screenshots, UI mockups, and images containing text. These compress extremely well losslessly and would look terrible with lossy compression because the sharp edges and flat colours are exactly the features JPG's 8×8 block structure handles worst.
Simple rule: Photographs → lossy (JPG or WebP lossy). Graphics, logos, screenshots, text → lossless (PNG or WebP lossless). When in doubt: if an image came from a camera, use lossy. If it came from a design tool, use lossless.
Different image formats are tied to specific compression approaches — some support only one type, others offer both:
| Format | Compression type | Transparency | Best for |
|---|---|---|---|
| JPG / JPEG | Lossy only | No | Photographs, complex images |
| PNG | Lossless only | Yes (8-bit alpha) | Graphics, logos, screenshots, transparency |
| WebP | Both modes | Yes (8-bit alpha) | All web images — replaces both JPG and PNG |
| AVIF | Both modes | Yes (full alpha) | Modern web images, HDR content, fine photography |
| GIF | Lossless | Yes (1-bit, binary) | Simple animations only (256 colour limit) |
| HEIC / HEIF | Both modes | Yes | iOS photography; limited web support |
| SVG | Vector (no raster compression) | Yes | Icons, logos, illustrations — infinitely scalable |
| RAW (CR3, NEF, ARW…) | Effectively lossless | N/A | Camera source files; not for web delivery |
The rise of WebP and AVIF as dual-mode formats is significant: they eliminate the historical trade-off between "lossy for photos" and "lossless for graphics." A single format can now handle both cases with better compression than the legacy formats it replaces, which simplifies image pipelines considerably.
Most image editors and compression tools expose a quality slider for JPG and WebP, typically on a scale of 1–100 (or sometimes 0–100). This number controls how aggressively the DCT coefficients are quantised — essentially, how much fine detail is discarded in the name of a smaller file.
The relationship between quality setting and file size is not linear. Moving from quality 100 to quality 90 can cut file size in half with almost no visible impact. Moving from quality 70 to quality 60 produces a much smaller incremental size saving but may introduce clearly visible artefacts. The relationship is roughly logarithmic: each step down the quality scale produces diminishing returns in file size savings but accelerating quality damage.
A practical breakdown for web use:
Important: The quality number is not standardised across tools. Quality 80 in Photoshop does not produce the same output as quality 80 in GIMP, ImageMagick, or a browser canvas export. Always evaluate the actual output visually rather than relying solely on the quality number as a cross-tool comparison.
Beyond the quality slider, JPG (and some WebP and HEIC encodings) apply a second, largely hidden form of compression called chroma subsampling. This technique exploits a fundamental property of human vision: our eyes are much more sensitive to variations in brightness (luminance) than to variations in colour (chrominance).
JPG separates image data into one luminance channel (Y) and two colour channels (Cb and Cr). Chroma subsampling reduces the resolution of the colour channels independently of the luminance channel. Three subsampling ratios are commonly used:
For most photographs, 4:2:0 subsampling is completely invisible in practice. Where it matters is for images with text, logos, or sharp colour boundaries at small sizes. If you're compressing an image that contains coloured text or fine colour detail, switching to 4:4:4 or 4:2:2 subsampling will improve colour accuracy at the cost of a slightly larger file.
Artefacts are the visual defects introduced by lossy compression. Knowing what to look for helps you calibrate your quality settings more confidently.
JPG blocking: The most recognisable JPG artefact. Because JPG compresses in 8×8 pixel blocks, aggressive compression makes those block boundaries visible as a grid of subtle rectangles, particularly in smooth areas like blue skies, skin, and gradients. Increasing quality to 75+ typically eliminates visible blocking at normal screen sizes.
Ringing (or "mosquito noise"): Appears as a bright or dark halo or fringe around sharp edges — most visible around text, logo outlines, and high-contrast transitions. Caused by the DCT transformation over-representing high-frequency edge content. Particularly problematic for screenshots containing text compressed as JPG rather than PNG.
Colour banding: Appears in gradients as a stepped, posterised effect instead of a smooth transition. Can be caused by both lossy compression and by saving gradients with too few colours (common with GIF or low-colour PNG).
Colour smearing: Caused primarily by 4:2:0 chroma subsampling — fine colour details bleed into surrounding areas, making sharp red, blue, or cyan details look softer or shifted.
WebP artefacts at similar quality settings tend to look softer and less blocky than JPG artefacts — more like blur than rectangular blocking. AVIF artefacts at heavy compression are even more natural-looking, degrading as smooth smearing rather than geometric patterns. This is part of why both newer formats are preferred over JPG at aggressive compression settings.
Cutting through the theory, here are the practical settings that work for the most common web image use cases in 2026:
Getting good compression results is as much about workflow as about settings. Here are the practices that produce consistently clean results:
Image compression has a direct, measurable impact on Google's Core Web Vitals metrics, which are used as search ranking signals. The most affected metric is Largest Contentful Paint (LCP), which measures how quickly the largest visible element on the page — usually a hero image or banner — loads and becomes visible to the user.
Google's threshold for a "good" LCP score is under 2.5 seconds. A 3 MB unoptimised JPG hero image on a typical mobile connection (averaging around 10–15 Mbps in practice) will take 1.5–3 seconds just for the image alone, without accounting for DNS, TLS handshake, HTML parsing, and CSS rendering. A properly compressed WebP version of the same image at 150–200 KB loads in under 0.15 seconds — a 10–20× difference.
Practical file size targets for Core Web Vitals:
LCP is also affected by whether the browser discovers the image early. Ensure hero images are referenced directly in the HTML (not loaded via JavaScript or CSS background-image) and add a <link rel="preload"> tag in the document head to prompt the browser to start fetching the image as early as possible in the loading sequence.
Compress your images for free — no upload, no account, runs entirely in your browser.
Compress images free →