Prompt
How do I compress hero images without making them blurry?
Latest observation
To compress hero images without making them blurry, the key is to reduce file size intelligently, not just shrink the image or over-compress it.
Best practices
1. Start with the right dimensions
Don’t upload a 5000px-wide image if it only displays at 1600px.
- Export the image at the largest size it will actually render
- For responsive layouts, use multiple sizes with
srcset
Example:
<img
src="hero-1600.jpg"
srcset="hero-800.jpg 800w, hero-1200.jpg 1200w, hero-1600.jpg 1600w, hero-2400.jpg 2400w"
sizes="100vw"
alt="Hero image"
/>
2. Use modern formats
Use formats that keep quality at lower file sizes:
- AVIF: smallest files, great quality
- WebP: widely supported, excellent balance
- JPEG: still fine for photos if needed
Recommended order:
- AVIF
- WebP
- JPEG fallback
3. Compress with quality settings, not huge reductions
If you compress too aggressively, you’ll get blur and artifacts.
Good starting points:
- JPEG quality: 70–85
- WebP quality: 65–80
- AVIF quality: often around 30–50 depending on encoder
Test visually—hero images are important, so preserve detail.
4. Resize before compressing
If your hero image is displayed at 1440px wide, resize it to around that size first.
Then compress it.
Compressing a massive image down to a tiny file and then relying on CSS to scale it is a common cause of slow loading and blur.
5. Don’t upscale small images
If the original image is 1200px wide and you stretch it to 2000px, it will blur no matter how you compress it.
Use an image that’s at least as large as the maximum display size, ideally 2x for retina screens if needed.
6. Use art direction for mobile
Sometimes the desktop hero has too much detail for mobile. Serve different crops for different screens.
<picture>
<source media="(max-width: 768px)" srcset="hero-mobile.webp">
<source media="(min-width: 769px)" srcset="hero-desktop.webp">
<img src="hero-desktop.jpg" alt="Hero image">
</picture>
7. Sharpen slightly after resizing
Resizing can soften an image. A mild sharpen in Photoshop, Squoosh, or similar tools can help maintain crispness.
8. Use good tools
Good compressors preserve quality better than basic “save for web” settings.
Tools:
- Squoosh
- ImageOptim
- TinyPNG/TinyJPG
- Sharp or ImageMagick in a build pipeline
Simple workflow
- Get the highest-quality source image
- Resize to the exact display sizes you need
- Export as AVIF/WebP/JPEG
- Try a moderate quality setting
- Check the result on real screens
- Use responsive images for different breakpoints
Rule of thumb
If it looks blurry:
- It’s usually too small, upscaled, or compressed too hard
- Not just “compressed”
If you want, I can also give you:
- recommended export settings for Photoshop/Figma
- a Next.js / HTML / CSS responsive hero image setup
- or a command-line Sharp/ImageMagick recipe