How to compress photos for the web
A photo can look crisp on a page without carrying every pixel from your camera. Start with the dimensions your layout actually needs, then compare a few compression settings side by side.
Start with the display size
If your image is displayed at 600 CSS pixels wide, try exporting it at 1,200 pixels to cover many high-density screens. A 4,000-pixel camera original can be useful for editing, but the page usually needs a smaller copy. Keep the original and resize a separate export.
Run a small quality comparison
Try WebP at 80% quality. Compare the result with a second export at 65%. Look at hair, lettering, and sky gradients at the size readers will see. Increase quality if edges break up, fine texture disappears, or bands appear across smooth colors.
Check the downloaded size
For a 1 MB original, a 250 KB export is about 75% smaller. The right target depends on the layout and the photo. Already-optimized images can get larger on re-encoding, so compare byte sizes before replacing the original file.
What compression actually does
Compression shrinks a file by removing information the eye is unlikely to miss. Lossy formats such as JPG and WebP throw away fine detail, smooth out tiny colour changes, and simplify areas that look flat, like a clear sky. Lossless formats such as PNG keep every pixel exactly, which is why PNG files are usually much larger. A phone photo straight from the camera can be 4 to 6 MB because it stores far more detail than any screen shows. On a web page, that same photo at 1,200 pixels wide and 80% quality can be 150 to 250 KB and look identical at normal viewing distance. The trick is to remove the invisible detail and keep the visible detail, which is why comparing a few settings side by side matters more than picking one magic number.
A simple five-step workflow
- Start from the original. Keep the full-resolution camera file untouched in a separate folder, and work on a copy. If a compressed version ever looks wrong, you can always go back and export again.
- Resize first. Decide how wide the image will appear on the page, then export at about twice that width. A photo shown at 600 pixels wide usually needs a 1,200-pixel file, not a 4,000-pixel one.
- Pick the format. Use WebP for most website photos, JPG when you need the widest compatibility, and PNG only for graphics with sharp text or transparency.
- Try two quality settings. Export at 80% and at 65%, then open both at the size readers will see. Pick the smaller file unless you can spot a real difference in hair, lettering, or smooth gradients.
- Check the final file size. Open the exported file and look at its size in kilobytes. If it is still above your target, lower the quality a little or reduce the dimensions, then check again.
Pick a file size target
A useful target for a photo inside an article is 100 to 200 KB. A large hero image at the top of a page can go up to 250 to 300 KB, and a small thumbnail should stay under 100 KB. These are targets, not hard rules: a detailed landscape will need more room than a simple product shot at the same size. The reason targets help is mobile data. A page with five uncompressed 3 MB photos asks a visitor to download 15 MB before anything looks finished, and many readers will leave before that happens. Keep the total weight of the images on a page under 1 MB when you can, and the page will feel fast on a phone as well as on a desktop.
Common mistakes to avoid
- Compressing your only copy. Always keep the original. A compressed file cannot be uncompressed back to full quality, so a mistake becomes permanent if there is no backup.
- Compressing the same JPG again and again. Every lossy save throws away a little more detail. Edit from the original each time instead of re-saving the small file.
- Judging quality at 200% zoom. Readers see the image at its display size, so judge it there. A photo that looks rough when zoomed in can look perfect on the page.
- Forgetting the format. A photo saved as PNG can be ten times larger than the same photo as a JPG. If the file seems stubbornly large, the format is often the reason.
An example: from 5 MB to 180 KB
Take a typical phone photo: 4,032 × 3,024 pixels, about 5 MB as a JPG. It is going into a blog post where it will display at 700 pixels wide. First, resize a copy to 1,400 pixels wide, which is twice the display width for sharp screens. That step alone brings the file to roughly 600 KB. Next, export it as WebP at 80% quality, which brings it to about 180 KB. The final image is 96% smaller than the original, it loads in a fraction of a second on mobile data, and at the size readers see it, the two versions are hard to tell apart. That is the whole point of compression: the same picture, a fraction of the weight.
Related guides
How to compress a PNG for the web →
Frequently asked questions
What quality setting should I start with?
Start at 80% for JPG or WebP. It is a good default for photos: files shrink a lot while visible quality stays high. Drop to 65 to 70% for large background images where fine detail matters less, and go up to 85 to 90% for photos where faces or products are the focus.
Does compressing an image make it blurry?
Not if you do it once, from the original, at a sensible setting. Blurriness usually comes from compressing the same file several times, or from enlarging a small image. Keep the original safe, export a fresh compressed copy, and check the result at its real display size.
Should I use JPG or WebP?
Use WebP for images on your own website, where it is usually 25 to 35% smaller than JPG at similar quality. Use JPG when the image will be emailed, printed, or opened in older software, because JPG works almost everywhere and WebP still does not.
Why did my compressed file get bigger?
That happens when the original was already well optimised, or when you convert a small JPG to PNG, which is a lossless format. Compare the byte size of the new file with the old one before replacing it, and keep whichever is smaller.