How to Compress a JPEG: What Actually Happens and What You Should Know

JPEG compression is one of those things most people do without really understanding — and that gap in understanding can lead to images that are blurry when they shouldn't be, or files that are far larger than necessary. Here's a clear breakdown of how it works, what affects the outcome, and why the "right" level of compression depends entirely on your situation.

What JPEG Compression Actually Does

JPEG uses lossy compression, which means it permanently discards image data to reduce file size. Unlike formats such as PNG or TIFF (which are lossless and preserve every pixel), JPEG achieves its small file sizes by simplifying color and detail information in ways the human eye often won't notice — at least at moderate compression levels.

The process works in stages:

  1. The image is converted from RGB color into a format that separates brightness from color information
  2. The image is divided into small 8×8 pixel blocks
  3. A mathematical process called the Discrete Cosine Transform (DCT) identifies which fine details can be discarded
  4. Higher compression = more data thrown away per block

The result is a smaller file — but one that cannot recover the discarded information. Every time you re-save a JPEG, it compresses again from whatever data remains, degrading quality further. This is called generation loss, and it's one of the most important practical facts about the format.

The Quality Setting: What the Numbers Mean 🎛️

Most image editing tools expose compression through a quality slider, typically ranging from 0–100 or 1–12 depending on the application. These numbers are not standardized across software — a "quality 80" in one tool is not identical to "quality 80" in another.

What is consistent is the relationship:

Quality LevelFile SizeVisual Impact
Very high (85–100)LargeMinimal or no visible loss
Medium (60–80)ModerateSlight softening at close inspection
Low (30–60)SmallVisible artifacts, blocky areas
Very low (below 30)Very smallSignificant degradation, blocking

For most web use, quality settings between 70 and 85 hit the sweet spot of acceptable visual quality and reasonable file size. But "acceptable" is a judgment call that depends on the image content, the display size, and who's looking.

Tools You Can Use to Compress a JPEG

There's no shortage of options. They fall into a few categories:

Desktop software

  • Image editors like Photoshop, GIMP, or Affinity Photo offer granular quality control when exporting. Photoshop's "Save for Web" panel, for example, lets you preview file size and quality side-by-side before committing.

Online tools

  • Browser-based tools process images without requiring software installation. Many are free and work directly in your browser without uploading to an external server — though you should check each tool's privacy policy before processing sensitive images.

Command-line tools

  • Tools like jpegoptim and mozjpeg (Mozilla's optimized JPEG encoder) give developers and power users precise control and are commonly used in automated workflows. mozjpeg in particular can often reduce file size compared to standard JPEG encoders at equivalent quality levels.

Operating system built-ins

  • macOS Preview can export JPEGs at reduced quality. Windows' built-in Photos app offers basic compression on export. These are convenient but offer less control than dedicated tools.

Variables That Change Everything

Compression isn't one-size-fits-all. These factors meaningfully shift what approach makes sense:

Image content Photographs with complex textures (foliage, fabric, skin) show JPEG artifacts differently than images with flat colors or sharp geometric edges. A portrait might compress well at quality 75 while a screenshot with text becomes noticeably degraded at the same setting.

Intended display size An image displayed at 400px wide on a webpage can tolerate more compression than the same image printed at full size. Compression that looks fine on screen may reveal artifacts in print.

Whether you have the original 🖼️ If you're working from a previously compressed JPEG, you're already working with lost data. Re-compressing will compound artifacts. Whenever possible, compress from the original raw or lossless source file.

Use case Email attachments, social media uploads, e-commerce product photos, and print-ready files all have different requirements — often defined by the platform itself. Many platforms (Instagram, Facebook, Google) re-compress your images anyway on upload, which affects the final result regardless of what you submitted.

Batch vs. single-image needs Manually adjusting individual images is practical at small scale. For bulk workflows — resizing and compressing hundreds of product images, for example — automated tools or scripts become necessary, and the tradeoffs between quality and consistency shift.

What JPEG Compression Can't Fix

Compression reduces file size — it doesn't fix exposure problems, improve sharpness, or recover blown highlights. It also can't undo previous compression. If an image already looks degraded, lowering the quality setting further compounds the problem rather than solving it.

There's also a format question worth considering. For images where transparency matters, PNG remains appropriate. For photography on the web where both quality and file size are priorities, WebP has become a widely supported modern alternative that often achieves smaller files than JPEG at comparable visual quality. Whether it's the right choice depends on your audience's browser compatibility needs and your existing workflow.

The right compression level for your JPEG ultimately comes down to where the image will live, how it will be displayed, how much degradation is acceptable for that context, and what tools you have in your workflow. Those are variables only your specific situation can answer.