Skip to main content
Compression

JPEG Compression Best Practices: Quality & Optimization

How JPEG compression works, which quality to use for thumbnails, blog photos and product shots, chroma subsampling, and progressive vs baseline.

By ImgCompress.appUpdated 14 min read
JPEG compression quality settings comparison showing optimization levels and file size reduction

JPEG has been the backbone of web photography since the early 1990s, and it is not going anywhere. Despite the rise of WebP and AVIF, JPEG still accounts for over 40% of all image bytes transferred on the web according to the HTTP Archive Web Almanac 2024. Every browser supports it, every image editor exports it, and every CMS handles it without configuration. If you work with images on the web, you need to understand how JPEG compression works and how to get the most out of it.

The challenge is that JPEG is a lossy format, and the quality slider in your compression tool is doing a lot more under the hood than most people realize. In our benchmark, mozjpeg files at quality 75 were about 40% smaller than at quality 85, a difference that is hard to see at normal viewing size. Push much lower and gradient areas start to show banding.

This guide breaks down the technical foundations of JPEG compression, gives you concrete quality settings for every common use case, and walks you through optimizing JPG files with ImgCompress.app, using numbers from our own benchmark.

How JPEG Compression Works Under the Hood

Understanding the compression pipeline helps you make smarter decisions about quality settings. The JPEG standard, formally defined in the ITU-T T.81 specification published by the International Telecommunication Union, uses a multi-stage process to reduce file size. Each stage offers a different lever for trading quality against file size.

Color Space Conversion and Chroma Subsampling

The first step converts the image from RGB (red, green, blue) to YCbCr color space. Y represents luminance (brightness), while Cb and Cr represent chrominance (color difference). This separation matters because human vision is far more sensitive to changes in brightness than to changes in color. The JPEG encoder exploits this biological fact through a technique called chroma subsampling.

Chroma subsampling reduces the resolution of the color channels while keeping the luminance channel at full resolution. The three common subsampling ratios are:

  • 4:4:4 — No subsampling. All three channels are stored at full resolution. This preserves maximum color accuracy but offers the least compression benefit. Use this for images where color precision is critical, such as product photography with saturated colors or medical imaging.
  • 4:2:2 — The color channels are sampled at half the horizontal resolution of the luminance channel. This cuts chrominance data by roughly 33% with minimal visible impact on most photographs. It is a good middle ground for high-quality web images.
  • 4:2:0 — The color channels are sampled at half resolution in both horizontal and vertical directions, reducing chrominance data by 75%. This is the default for most JPEG encoders and web compression tools, including ImgCompress.app. For typical photographic content viewed at web display sizes, the quality difference compared to 4:4:4 is negligible.

As documented in the Mozilla MDN Web Docs on JPEG, the 4:2:0 subsampling scheme is the most widely used configuration on the web because it delivers the best balance of file size and perceptual quality for photographic content.

A 4×4 pixel area after the switch to YCbCr: the brightness plane Y, then the two colour planes Cb and Cr. At 4:4:4 every plane keeps 16 samples; at 4:2:0 each colour plane keeps 4, one per 2×2 pixels. Colour data drops by 75% and the whole area by half.

Discrete Cosine Transform (DCT)

After color space conversion, the encoder divides each channel into 8×8 pixel blocks and applies the Discrete Cosine Transform to each block. The DCT converts spatial pixel data into frequency coefficients — essentially decomposing the block into a set of cosine wave patterns at different frequencies.

Low-frequency coefficients represent the broad color and brightness gradients in the block. High-frequency coefficients represent fine details like sharp edges, texture, and noise. The key insight is that most of the visual information in a typical photograph is concentrated in the low-frequency coefficients. The high-frequency data can often be reduced or eliminated without the viewer noticing.

Quantization: Where Quality Loss Actually Happens

Quantization is the step where data is permanently discarded, and it is directly controlled by the quality setting you choose. The encoder divides each DCT coefficient by a corresponding value from a quantization table, then rounds the result to the nearest integer. Larger divisors in the quantization table mean more aggressive rounding, which means smaller files but more information lost.

When you move the quality slider from 90 down to 70, you are telling the encoder to use a quantization table with larger divisors, especially for the high-frequency coefficients. This is why compression artifacts in JPEG images typically appear as blockiness (the 8×8 block boundaries become visible) and ringing (halos around sharp edges) — these are the visual consequences of quantizing away high-frequency detail.

① The DCT turns an 8×8 block into 64 frequency coefficients; broad tones sit top left, fine detail toward the bottom right. ② Each coefficient is divided by its entry in the quantization table (here the standard quality-50 table) and rounded. In this worked example 44 of the 64 values become 0, which the entropy coder stores in very few bits. Lower quality means larger divisors and more zeros.

Entropy Coding

The final stage applies lossless entropy coding (Huffman coding in baseline JPEG, or arithmetic coding in some implementations) to the quantized coefficients. This step compresses the data further without any additional quality loss. There is not much you can do to influence this stage as an end user, but optimized JPEG encoders like MozJPEG apply more efficient Huffman tables than the standard ones, squeezing out an extra 2–5% file size reduction at no quality cost.

Quality Settings Guide: What to Use and When

The quality slider is the most important control you have when compressing JPEG images. These ranges are starting points, not measurements; check the result on your own images:

Use CaseQuality RangeNotes
Thumbnails (< 300px)60–70%Small display size masks artifacts effectively
Social media images70–80%Platforms re-compress on upload anyway
Standard blog photos75–85%Sweet spot for most web content
Hero and banner images85–90%Higher quality justified for prominent placement
Product photography82–90%Preserve detail for purchase decisions
Print-ready images92–100%Minimal compression, maximum fidelity

About SSIM scores: The Structural Similarity Index (SSIM) measures perceived visual quality on a scale from 0 to 1, where 1.0 means identical to the original. Scores above 0.95 are generally considered visually lossless to most viewers. Scores above 0.98 are indistinguishable from the original even under close inspection. In our own benchmark, mozjpeg photos at quality 80, resized to 1920 px, scored between 0.978 and 0.982, measured with the SSIM algorithm described in the original Wang et al. 2004 paper.

The 80% Rule of Thumb

If you are unsure where to start, quality 80 is the single best default for photographic JPEG content on the web. At this setting, you typically get:

  • A file far smaller than the camera original, especially once the photo is resized for the web
  • SSIM scores in the high 0.9s (0.978–0.982 for mozjpeg at quality 80 on three photos in our benchmark)
  • No visible blocking or ringing artifacts at typical web display sizes (up to about 1200px wide)

From quality 80, you can adjust up or down based on the specific image and context. Images with large smooth gradients (sky, skin tones) may benefit from bumping up to 85 to avoid banding. Images with lots of fine texture (foliage, fabric) can often drop to 75 without any visible difference.

Quality vs File Size: The Diminishing Returns Curve

One of the most important things to understand about JPEG quality settings is that the relationship between quality and file size is not linear. In our benchmark we encoded three full-resolution photos with mozjpeg at quality 85 and 75:

PhotoQuality 85Quality 75Size at Q75 vs Q85
Landscape (5184×3456)1,382 KB (SSIM 0.963)839 KB (SSIM 0.946)−39%
Portrait (8256×5504)2,574 KB (SSIM 0.987)1,534 KB (SSIM 0.962)−40%
Product (4080×3072)875 KB (SSIM 0.984)521 KB (SSIM 0.967)−40%

Ten quality points removed about 40% of the file size while SSIM fell by 0.018 to 0.025. The higher you start, the more bytes each quality step costs; below about quality 50, artifacts become clearly visible in most photographic content.

This is why the 80–85 range is the sweet spot for most web use cases. You capture the vast majority of the compression benefit while staying well within the perceptually lossless zone.

Progressive JPEG vs Baseline JPEG

JPEG files come in two encoding modes: baseline and progressive. The difference affects how the image loads in the browser, and it can also affect file size.

Baseline JPEG

Baseline encoding stores the image data in a single top-to-bottom scan. The browser renders the image row by row as the data arrives. On a slow connection, you see the top portion of the image first, with the rest appearing as more data downloads. This can feel sluggish because the viewer has no sense of the overall image until most of it has loaded.

Progressive JPEG

Progressive encoding stores the image in multiple scans of increasing detail. The first scan contains a low-resolution version of the entire image. Subsequent scans add more detail until the full-quality image is complete. The browser displays the blurry preview almost immediately and sharpens it as more data arrives.

Which Should You Choose?

For web delivery, progressive JPEG is almost always the better choice, and here is why:

  • Perceived performance — Users see a complete (if blurry) image much sooner, which feels faster even if the total download time is identical. This is especially valuable for hero images and above-the-fold content.
  • File size — For images larger than about 10 KB, progressive JPEG files are often slightly smaller than their baseline equivalents (typically 2–5% smaller). This is because the multi-scan structure allows the entropy coder to work more efficiently across the frequency spectrum.
  • Compatibility — Every modern browser handles progressive JPEG correctly. There are no compatibility concerns in 2025.

The only scenario where baseline might be preferable is for very small images (under 10 KB), where the overhead of the progressive scan structure can actually make the file slightly larger. For thumbnails under 5 KB, the difference is negligible either way.

ImgCompress.app encodes JPEGs with your browser's built-in encoder, which writes baseline files. If you need progressive JPEGs, use an encoder such as mozjpeg (for example in Squoosh or sharp).

Tutorial: Optimizing JPEG Images with ImgCompress.app

Let us walk through a practical optimization workflow, then look at what the default settings did to three real photos in our benchmark.

Step-by-Step Process

  1. Visit ImgCompress.app in your browser.
  2. Drag your JPEG files onto the upload area. You can drop up to 10 files of up to 50 MB each at once.
  3. Select JPEG as the output format and set your desired quality level using the slider.
  4. Click compress. In our benchmark each photo took 88 to 694 ms, depending on its resolution; your device may be faster or slower.
  5. Use the before-and-after preview to inspect the result at full zoom. Pay attention to gradient areas, fine textures, and sharp edges — these are where artifacts appear first.
  6. Download the compressed file, or download all files as a ZIP if you processed a batch.

Results with the Default Settings

On 5 October 2026 we ran three CC0 photos through the compressor with its defaults (quality 80%, longest side capped at 1920 px):

ImageOriginalAfter compressionReductionSSIM
Landscape (5184×3456)2.92 MB250 KB−91.4%0.979
Portrait (8256×5504)12.0 MB154 KB−98.7%0.960
Product (4080×3072)2.42 MB249 KB−89.7%0.986

Most of that reduction comes from the resize to 1920 px. At that same size, mozjpeg at quality 80 made files 26–40% smaller than the browser encoder we use, so if every kilobyte counts, a dedicated encoder will do better. Full method and data: our image compression tools comparison.

Common JPEG Compression Mistakes and How to Avoid Them

Even experienced developers make these mistakes when working with JPEG compression. Here are the most common pitfalls and how to sidestep them.

Re-compressing Already Compressed JPEGs

This is the single most damaging mistake. Every time you open a JPEG, edit it, and save it again as JPEG, you run the image through the full lossy compression pipeline again. Each generation introduces additional quantization artifacts that compound on top of the previous ones. After three or four rounds of re-compression, the quality degradation becomes clearly visible — especially in areas with smooth gradients or fine detail.

The fix: Always keep your original high-quality source files (RAW, TIFF, or maximum-quality JPEG). Compress from the source every time you need a new output. If you need to convert a JPEG to another format, our Image Format Conversion Guide explains how to minimize quality loss during the process.

A second pass can also make the file larger instead of smaller, for example when the first save used a lower quality than your new setting; why a compressed image gets bigger shows measured cases.

Using Quality 100 for Web Images

Quality 100 does not mean "no compression." It means "minimum quantization," and the resulting files are enormous — often 3–5× larger than quality 90 with no perceptible visual difference. Dropping from 100 to 90 removes a large share of the bytes while the visible difference stays negligible.

The fix: Never use quality 100 for web delivery. Start at 80 for general use and only go above 90 if you have a specific reason (print preparation, archival storage).

Ignoring Chroma Subsampling Settings

Most compression tools default to 4:2:0 chroma subsampling, which is correct for the vast majority of photographic content. However, if you are compressing images with fine color detail — such as product photos with saturated reds and blues, or images containing thin colored lines — 4:2:0 can cause visible color bleeding at edges.

The fix: For images where color accuracy is critical, check whether your compression tool offers a 4:4:4 subsampling option. The file will be larger, but the color fidelity will be preserved. For standard web photos, 4:2:0 is the right default.

Compressing Screenshots and Graphics as JPEG

JPEG is designed for continuous-tone photographic content. Images with sharp edges, solid color blocks, and text — like UI screenshots, logos, charts, and diagrams — compress poorly as JPEG and often show visible ringing artifacts around edges.

The fix: Use PNG for screenshots and graphics that need lossless quality, or WebP for a good balance of quality and file size. See our WebP vs PNG comparison for a detailed breakdown of when to use each format.

Not Testing on Multiple Devices

Compression artifacts that are invisible on a desktop monitor may be noticeable on a high-DPI mobile screen, or vice versa. The viewing distance, screen size, and pixel density all affect how artifacts are perceived.

The fix: Always preview your compressed images on at least one mobile device in addition to your desktop. Pay particular attention to hero images and product photos that are critical to the user experience.

Conclusion

JPEG compression is deceptively simple on the surface — move a slider, get a smaller file — but the technical details matter. Understanding how DCT, quantization, and chroma subsampling interact gives you the knowledge to make informed decisions about quality settings instead of guessing.

The practical takeaways are straightforward: use quality 80 as your default starting point, prefer progressive encoding when your encoder offers it, always compress from your highest-quality source file, and match your quality setting to the image's display context. Thumbnails can go as low as 60–70%. Hero images deserve 85–90%. And quality 100 is almost never the right answer for web delivery.

Ready to optimize your JPEG images? Try our free image compressor — it processes everything locally in your browser and handles up to 10 files per batch. No signup and no file uploads.

Related reading:

  • JPEG compression
  • JPG optimization
  • quality settings
  • lossy compression
  • progressive JPEG