How to Compress JPEG Images: Complete Guide (2026)
Compress JPEG images without visible quality loss. The right settings and tools for web optimization.
How to Compress JPEG Images: Complete Guide (2026)
JPEG compression doesn't have to mean bad quality. Here's how to compress without visible loss.
Most people compress JPEG wrong. They either over-compress (ugly) or under-compress (wasteful). Here's the right way.
Understanding JPEG Compression
How JPEG Works
JPEG divides image into 8x8 blocks, analyzes patterns, and discards "invisible" detail. More compression = more discarded detail.
Quality Levels
| Quality | Compression | Typical Use |
|---|---|---|
| 100% | None | Archives |
| 90% | Light | High-quality prints |
| 80-85% | Medium | Web (recommended) |
| 70% | Heavy | Thumbnails |
| 60% | Extreme | Last resort |
Visible Quality Thresholds
After testing hundreds of images:
- 90-100%: No visible difference
- 80-89%: Usually invisible
- 70-79%: Sometimes visible
- <70%: Usually visible
Recommendation: 80-85% for web
How to Compress JPEG
Method 1: Imagic AI (Easiest)
Best for: Most users
- Upload JPEG
- Compression level slider
- Download
Time: 5 seconds
Method 2: Python
from PIL import Image
def compress_jpeg(input_path, output_path, quality=85):
img = Image.open(input_path)
# Convert RGBA to RGB if needed
if img.mode == 'RGBA':
img = img.convert('RGB')
# Save with compression
img.save(
output_path,
'JPEG',
quality=quality,
optimize=True,
progressive=True # Progressive JPEG
)
# Compress at 85% quality
compress_jpeg('photo.jpg', 'compressed.jpg', quality=85)
Method 3: Command Line
# ImageMagick
convert input.jpg -quality 85 -strip output.jpg
# jpegoptim
jpegoptim --max=85 photo.jpg
# cjpeg
cjpeg -quality 85 input.ppm > output.jpg
Progressive JPEG
Progressive JPEGs load in stages (fuzzy → sharp) instead of top-to-bottom. Same quality, better perceived performance.
from PIL import Image
img = Image.open('photo.jpg')
img.save('progressive.jpg', 'JPEG', quality=85, progressive=True)
Batch Compression
from PIL import Image
from pathlib import Path
def batch_compress(input_dir, output_dir, quality=85):
output_dir = Path(output_dir)
output_dir.mkdir(exist_ok=True)
for f in Path(input_dir).glob('*.jpg'):
img = Image.open(f)
if img.mode == 'RGBA':
img = img.convert('RGB')
img.save(
output_dir / f.name,
'JPEG',
quality=quality,
optimize=True,
progressive=True
)
batch_compress('./photos', './compressed', quality=85)
Compress vs Resize
Both reduce file size, but differently:
| Action | Effect |
|---|---|
| Compress | Same size, smaller file |
| Resize | Smaller size, smaller file |
Best approach: Do both
from PIL import Image
def optimize_for_web(input_path, output_path, max_size=1920, quality=85):
img = Image.open(input_path)
# Resize if needed
if max(img.size) > max_size:
ratio = max_size / max(img.size)
img = img.resize(
tuple(int(d * ratio) for d in img.size),
Image.Resampling.LANCZOS
)
# Convert and compress
if img.mode == 'RGBA':
img = img.convert('RGB')
img.save(
output_path,
'JPEG',
quality=quality,
optimize=True,
progressive=True
)
optimize_for_web('photo.jpg', 'web.jpg')
Target File Sizes
| Image Type | Target Size |
|---|---|
| Hero/Banner | 200-400 KB |
| Content | 50-150 KB |
| Thumbnail | 10-30 KB |
| Avatar | 5-15 KB |
Common Mistakes
Mistake 1: Over-Compressing
Problem: Visible artifacts
Solution: Don't go below 70%
Mistake 2: No Compression
Problem: Huge files
Solution: 80-85% is fine
Mistake 3: Wrong Format
Problem: PNG for photos (too large)
Solution: Use JPEG for photos
Mistake 4: Multiple Saves
Problem: Progressive quality loss
Solution: Edit original, save once
Quality vs File Size
I tested the same 3MB photo at different quality levels:
| Quality | File Size | Visible Loss |
|---|---|---|
| 100% | 2.8 MB | None |
| 90% | 520 KB | None |
| 85% | 280 KB | None |
| 80% | 180 KB | Rarely |
| 70% | 95 KB | Sometimes |
| 60% | 55 KB | Usually |
85% quality = 90% smaller, no visible loss
Tools I Use
| Tool | Best For |
|---|---|
| Imagic AI | Quick compression |
| Squoosh | Quality control |
| ImageOptim | macOS native |
| jpegoptim | Linux CLI |
FAQ
Q: Does JPEG compression reduce quality?
A: Yes, but 80-85% quality is usually invisible to the eye.
Q: How small can I compress JPEG?
A: 60-70% for thumbnails. Below 60% starts looking bad.
Q: Should I save multiple times?
A: No. Each save loses quality.
Q: What's the best JPEG quality for web?
A: 80-85% - best balance of size and quality.
Q: Can I compress already compressed JPEG?
A: Yes, but savings will be minimal. Better to start fresh.
Quick Checklist
Before uploading:
- [ ] Quality 80-85%?
- [ ] Right dimensions?
- [ ] Progressive encoding?
- [ ] Under 200KB?
My Recommendation
Start here: Try Imagic AI
For automation: Python scripts
For best quality: 85% quality, resize to display size
Compressing JPEGs for 15+ years.