Fixing Oversized Image Files
An oversized image file is one that weighs far more than it needs to for what the visitor sees. The usual culprits are a camera original uploaded as it came off the phone, a quality setting left at maximum, hidden metadata, and PNG files that were never optimised.
Every visitor pays for those bytes in load time and mobile data, and the heaviest image is often the one that decides how quickly the page appears. This guide shows how to find the heaviest files, where the wasted bytes hide, how to remove them without visible loss, and how to stop them coming back.
Large image files are usually the biggest single cause of slow pages.
What an oversized file finding means
This finding is about bytes: how many kilobytes or megabytes the browser downloads for an image. It is related to, but not the same as, the image's pixel dimensions or its format, which have their own findings and guides. A 1200 pixel wide JPEG can weigh 90 KB or 900 KB depending on how it was saved, and both look much the same on screen.
The weight matters for three reasons:
- Loading speed. The main image near the top of the page is often the Largest Contentful Paint element. A good LCP is 2.5 seconds or less at the 75th percentile, and a heavy hero image on a mobile connection can use most of that budget on its own.
- Data costs. Visitors on limited mobile plans pay for every megabyte. So do you, if your host or CDN charges for bandwidth.
- Competition for the connection. Several heavy images downloading together slow down each other and the fonts, scripts and styles the page also needs.
There is no single correct size for an image, and Google has no file-size rule. The right weight depends on how large the image is shown and what it contains. What the audit looks for is images clearly heavier than their job requires.
Where the wasted bytes hide
| Source of waste | How it happens | How to remove it |
|---|---|---|
| Too many pixels | A phone photo several thousand pixels wide uploaded for a column a fraction of that width. | Cap the long edge at upload; serve smaller versions with srcset. |
| Quality set too high | Cameras, phones and design tools often save JPEGs near maximum quality. | Re-encode at a lower setting chosen by eye. |
| Metadata | EXIF camera data, GPS location, editing history, embedded thumbnails and large colour profiles. | Strip on export or with a tool such as exiftool. |
| Unoptimised PNG | Default PNG export settings with no filtering or compression tuning. | Lossless optimisation with oxipng, or palette reduction with pngquant. |
| Full colour detail in JPEG | Saving with no chroma subsampling, keeping more colour detail than photos need. | Use 4:2:0 subsampling for photographs; keep full colour only for sharp coloured text. |
| Noise and grain | Photos taken in low light, or grain added as a style, compress badly. | Mild noise reduction before export, or accept a larger file for that image. |
| Wrong format | A photograph saved as PNG. | See the image format guide. |
Usually two or three of these combine. A typical oversized product photo is a phone original with too many pixels, saved at high quality, carrying its EXIF block. Fixing all three together is where the big savings come from.
Finding the heaviest images
On a single page
Run the Image Optimisation audit on your busiest templates first. To check a page by hand, open developer tools, go to the Network panel, tick "Disable cache", reload and filter by images. Sort the Size column from largest to smallest. Chrome shows two figures when you hover: the transferred size, which is what came over the network, and the resource size, which is the file after decoding any transfer compression. For images these are usually close, because image formats are already compressed.
Lighthouse also reports images it thinks could be smaller. In recent versions this appears as an image delivery insight; older versions split it into separate audits for encoding, sizing and format.
Across the whole site
If you have server access, list the largest files in the uploads folder. This finds heavy images that are not on the pages you happened to test.
# The 50 largest JPEG, PNG and WebP files over 300 KB
find /var/www/example/uploads -type f \
\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) \
-size +300k -printf '%s %p\n' | sort -rn | head -50
A crawler that records image sizes will give you the same list by URL, with the pages each image appears on, which helps you prioritise images used on popular pages.
Choosing a quality setting
Lossy formats trade file size against visual accuracy with a quality number. The relationship is not straight: going from the highest settings down to the upper middle of the range usually removes a lot of bytes with no difference most people can see, while going lower starts to show blocky areas, halos around edges and banding in smooth gradients such as skies.
Do not copy a quality number from another site or another tool. A given number means different things in different encoders and formats. Instead:
- Pick five or six typical images: a product shot, a photo with sky, a portrait, one with fine texture such as fabric.
- Open each in Squoosh or a similar tool and lower the quality while comparing side by side at the size it is shown on your site.
- Note the lowest setting where you cannot see a difference without zooming in. Use the highest of those across your sample as your standard.
- Apply that setting in your export presets, plugin or build script.
For JPEG, the mozjpeg encoder, available in Squoosh, sharp and as cjpeg, usually gives
smaller files than the default encoder at similar quality. Progressive JPEGs, which load as a rough version
that sharpens, are often slightly smaller for larger photos too.
Tools and commands that do the work
Desktop tools such as Squoosh in the browser and ImageOptim on macOS are fine for a handful of images. For hundreds or thousands, command-line tools are faster and repeatable. Test on copies first.
# Resize to fit within 2400 px, strip metadata, JPEG quality 80,
# 4:2:0 colour subsampling and progressive output (ImageMagick 7)
magick original.jpg -auto-orient -colorspace sRGB -resize "2400x2400>" \
-strip -quality 80 -sampling-factor 4:2:0 -interlace JPEG web.jpg
# Recompress existing JPEGs in place: cap quality, strip metadata, progressive
jpegoptim --max=80 --strip-all --all-progressive *.jpg
# PNG: lossless optimisation
oxipng -o 4 --strip safe *.png
# PNG graphics: reduce to a palette, keep the original if the result is bigger
pngquant --quality=65-85 --skip-if-larger --ext .png --force *.png
# Remove all metadata from a JPEG, keeping the file otherwise unchanged
exiftool -all= -overwrite_original photo.jpg
The > after the size in the ImageMagick command means only shrink, never enlarge.
Converting to sRGB before stripping matters: removing an embedded colour profile from an image saved
in a different colour space can shift its colours in the browser.
In a Node.js pipeline
import sharp from 'sharp';
await sharp('uploads/original.jpg')
.rotate() // apply camera orientation
.resize({ width: 2400, height: 2400, fit: 'inside', withoutEnlargement: true })
.jpeg({ quality: 80, mozjpeg: true }) // metadata is dropped by default
.toFile('public/img/web.jpg');
The fix, step by step
Step 1
Rank images by bytes transferred
Run the Image Optimisation audit on your busiest templates, then open the Network panel in developer tools with the cache disabled, filter by images and sort by size. For a site-wide view, list the largest files in the uploads folder or export image sizes from a crawler. Put the heaviest images used on popular pages at the top of your list, because they affect the most visits and the most bandwidth.
Step 2
Cap the pixel size of originals
Decide the largest size any image is ever shown on your layout, allow roughly double for high-density screens, and resize anything bigger down to that limit. A long edge of around 2000 to 2600 pixels covers most full-width layouts. Apply the cap at upload through your CMS, plugin or build step, so camera originals several thousand pixels wide never reach the public site in the first place.
Step 3
Lower quality until you can see a difference
Take a handful of typical images and compare them side by side in Squoosh at the size they appear on your site, lowering the quality step by step. Stop just above the point where you notice blockiness, halos or banding in smooth areas such as skies. Use that setting for the whole library, prefer the mozjpeg encoder for JPEGs, and always start from a good original.
Step 4
Strip metadata you do not need
Remove EXIF camera data, GPS location, editing history and embedded thumbnails from every image you publish, using your export settings, an optimisation plugin, or a tool such as exiftool or jpegoptim. Convert images to sRGB first so colours stay correct once the profile is gone. If you want a copyright notice kept in the file, keep that one field rather than all of the metadata.
Step 5
Shrink PNGs and graphics
Run PNG files through oxipng for lossless savings, and through pngquant where the image is a graphic, icon or illustration with limited colours, since reducing it to a palette often cuts the size sharply with no visible change. Check any photographs saved as PNG and move them to JPEG, WebP or AVIF instead. Replace logos and simple icons stored as PNG with optimised SVG where possible.
Step 6
Bulk-process the existing library
Back up the uploads folder, then run your chosen commands, plugin or script across existing images, starting with those on the busiest pages. Keep file names and addresses the same so pages, feeds and search results keep working. Purge the CDN and page caches afterwards so visitors receive the new files, and spot-check a sample of images at full size for quality problems.
Step 7
Set a weight budget and check it on release
Agree a maximum weight for each kind of image slot, such as hero, product main image, card thumbnail and article inline image, based on the results you achieved. Add a check to your build, a performance budget in Lighthouse CI, or a regular crawl that flags any image over its budget. Re-run the Image Optimisation audit after theme changes and large content uploads.
Cases that need a lighter touch
- Photography portfolios and zoom images. Where the picture is the product, visitors may expect fine detail. Keep a higher quality for the full-size view opened on demand, and compress the thumbnails and gallery views harder.
- Gradients, skies and dark scenes. These show banding first when compressed. Give them a slightly higher quality, or try WebP or AVIF, which often handle smooth areas better.
- Screenshots with small text. Lossy compression blurs text. Keep them lossless, or use lossless WebP.
- Privacy. Photos taken on phones may carry the exact location where they were taken. Stripping metadata protects staff and customers as well as saving bytes, which matters for photos of homes and private premises.
- Images from suppliers. Manufacturer photos are often supplied as very large files. Run them through the same pipeline as your own uploads instead of publishing them as delivered.
- Images in CSS. Background images in stylesheets do not show in the media library. Check the theme folder as well as uploads.
Keeping files light
- Optimise on upload, through the CMS, a plugin, an image CDN or a build step, so nobody has to remember.
- Set a maximum upload size in the CMS so extremely large originals are resized or refused.
- Give editors a simple rule: export at the largest size needed, not the camera size, and never upload screenshots of photos.
- Keep the budget visible in your release checks, and treat an image over budget like any other failed test.
- Review supplier and marketing assets before they go live, since they bypass the usual upload route.
For a wider view of how image weight fits into loading speed, see the Core Web Vitals Guide.
1. How many kilobytes should a website image be?
There is no single correct figure, and Google does not publish a file-size limit. The right weight depends on how large the image is shown and what it contains: a full-width photo can reasonably weigh more than a small product thumbnail. A practical approach is to optimise a few typical images well, note what they weigh, and use those results as a budget for each kind of image slot on your site. Anything far above that budget needs attention.
2. What JPEG quality setting should I use?
Choose it by eye rather than copying a number, because the same number gives different results in different encoders. Compare a few typical images side by side at the size they appear on your site, lower the quality step by step, and stop just above the point where you notice blockiness or banding. Many photos can go well below their camera default without any visible change. Use the mozjpeg encoder where you can for smaller files.
3. Does removing EXIF data make images smaller?
Yes, and sometimes by a meaningful amount. Photos from phones and cameras can carry camera settings, location, editing history, an embedded preview thumbnail and a colour profile, none of which the visitor sees. Stripping it reduces the file and removes location data that could reveal where a photo was taken. Convert the image to the sRGB colour space before stripping, so colours still display correctly once the embedded profile has been removed.
4. Will compressing images reduce their quality?
Lossy compression does discard information, but done at a sensible setting the difference is not visible at the size the image is shown. Problems appear when the quality is pushed too low, when an already compressed file is compressed again, or when screenshots with small text are treated like photographs. Compress from good originals, check results side by side, and keep lossless settings for text-heavy graphics. Lossless tools such as oxipng do not change the image at all.
5. Why are my PNG files so large?
Usually because they are photographs, which PNG stores without discarding anything, or because they were exported with default settings and never optimised. Photographs should be JPEG, WebP or AVIF instead. Graphics that genuinely need PNG can be run through oxipng for lossless savings, and through pngquant to reduce them to a palette of colours, which often cuts the size sharply for icons, illustrations and diagrams with no visible difference at normal viewing size.
6. Should I compress images before uploading or use a plugin?
Either works, and many sites use both. Compressing before upload gives you full control and keeps oversized files out of your storage entirely. A plugin, image CDN or build step does the same thing automatically, which is more reliable when several people upload images. The important thing is that every image passes through one of them. Avoid running two lossy optimisers one after the other, which compresses the same image twice.
7. Will re-compressing my existing images break anything?
Not if you keep the same file names and addresses, which most bulk tools and plugins do. Pages, product feeds and image search results keep pointing at the same URLs and simply receive smaller files. Take a full backup of the uploads folder first, test on a copy, and purge your CDN and page caches afterwards so visitors get the new versions. Spot-check a sample of images at full size before and after for any visible loss.
The Image Optimisation audit checks every image on your page for file size as well as format, dimensions, alt text, lazy-loading, layout shift and CDN delivery, and ranks its recommendations by their effect on loading and bandwidth.
Open Image Optimisation Fixes โ