Skip to the content
Start free

Image compression

Image compression is making a picture file smaller, in kilobytes, so it downloads faster, while keeping it looking good enough for the page. Lossless compression shrinks the file without changing a single pixel. Lossy compression throws away detail the eye is unlikely to miss, which saves far more. Most sites need both, plus the right format and the right size.

What is image compression? #

A photo from a phone can be 4 to 8 MB. On a product page it may show at 800 pixels wide, where 80 to 150 KB is often plenty. The gap is wasted download time for every visitor. Compression closes it in 3 ways:

  • Lossy encoding drops fine detail. A JPEG at a lower quality setting is the classic case.
  • Lossless encoding stores the same pixels more cleverly. PNG works this way.
  • Removing extras such as camera data (EXIF), colour profiles you do not need and embedded thumbnails.

Two related jobs often get lumped in: resizing (fewer pixels) and choosing a modern format. They are not compression in the strict sense, but they usually save the most.

Lossy or lossless? #

MDN’s image file type guide is clear on this. It says photographs and other continuous-tone images can usually take lossy compression, because the lost detail is harder to see. For screenshots, diagrams, logos and line art it says to prefer lossless, since blur and coloured fringes show up badly around text and sharp edges. For icons and charts that must stay sharp at any size, it points to SVG.

Format Compression Good for
JPEG Lossy Photos; the most widely supported
PNG Lossless Screenshots, transparency, exact copies
WebP Lossy or lossless Photos and graphics; MDN calls it an excellent choice
AVIF Lossy or lossless Photos; strong compression, royalty free
SVG Text-based vector Logos, icons, diagrams
GIF Lossless, 256 colours Tiny animations; video or WebP is usually smaller

See WebP and AVIF for the newer formats in detail.

Heavy images make slow pages, and slow pages lose visitors and rankings. Google’s image SEO best practices say images are often the largest part of a page’s size, which can make pages slow and costly to load. The same page lists the formats Google Images can index: BMP, GIF, JPEG, PNG, WebP, SVG and AVIF. So a modern format costs you nothing in image search.

The link to Core Web Vitals is direct. On many pages the biggest thing on screen is a hero picture, which makes it the Largest Contentful Paint element. web.dev’s guide to optimising LCP sets “good” at 2.5 seconds or less for at least 75% of visits. It names compressing the image harder or moving to a better format, such as AVIF or WebP, as ways to cut the time the LCP file takes to load. More on load times: page speed, plus our note on slow websites.

Why does it matter for AI answers? #

AI assistants that show pictures, and shopping agents that compare products, fetch the same files Google does. Smaller files are cheaper for every AI crawler to collect, and your server spends less bandwidth serving them. Do not over-squeeze, though. Google’s guide notes that sharp, high-quality pictures tend to do better as result thumbnails. A product shot that turns to mush at 40 KB helps no one. Good compression keeps the picture clear and its alt text accurate, so both people and machines know what it shows.

How does it work? #

  1. Resize first. Save the picture at the largest size it will ever show, not the camera size. Use srcset to offer 2 or 3 widths so phones get small files.
  2. Pick the format. Photos to AVIF or WebP with a JPEG fallback; graphics to SVG or lossless WebP or PNG. MDN suggests the picture element to serve several formats with a fallback.
  3. Set the quality. For lossy formats, try settings between about 60 and 85 and compare side by side.
  4. Strip the metadata. Camera data can also carry the place a photo was taken.
  5. Serve it well. Set width and height to avoid layout shift, use lazy loading below the fold, and let a CDN and caching do the rest.

Chrome’s Lighthouse has an audit called “Efficiently encode images”. Its documentation says it re-saves each JPEG or BMP at compression level 85 and flags the image if that would save 4 KiB or more.

Common mistakes #

  • Uploading the camera original and letting the browser shrink it on screen. The visitor still downloads every pixel.
  • PNG for photos. A lossless photo is usually far bigger than a good lossy copy of the same picture.
  • JPEG for logos and text. Edges go fuzzy. Use SVG.
  • Lazy loading the hero image. web.dev says never to lazy-load the LCP image, because it always adds delay.
  • Compressing twice. Re-saving an already lossy JPEG adds blur each time. Keep a master copy.
  • Animated GIFs. Lighthouse suggests video in their place.
  • Forgetting the fallback. Google recommends always giving an src on the img tag, as some browsers and crawlers ignore srcset and picture.

A worked example #

A shop’s home page hero is a 4,000 by 3,000 pixel photo shown at 1,200 pixels wide.

Step File Size
Camera original JPEG, 4,000 px 5.2 MB
Resized to 1,200 px JPEG, quality 90 410 KB
Quality set to 75, EXIF removed JPEG 190 KB
Saved as WebP WebP 125 KB
Saved as AVIF AVIF 85 KB

These sizes are an illustration; your own photos will vary. The pattern holds: resizing saves the most, format and quality save the next big slice.

How to check it #

  1. Run any page through our Image SEO Checker to see file sizes, formats, alt text and missing dimensions.
  2. Shrink files in your browser with our Image Compressor, change format with the Image Converter and cut size with the Image Resizer.
  3. Remove camera data with the EXIF Remover, after a look in the Image Metadata Viewer.
  4. Check images are cached properly with our Cache Checker, and that the server sends the right content type with our HTTP Header Checker.
  5. To time the page, our Page Speed Checker is coming soon. Use Google’s PageSpeed Insights or Lighthouse today.
  6. In URSY Pro, the Image SEO audit (Pro) and Asset diet report (Pro) track this across the whole site.

Questions #

What quality setting should I use? #

There is no one number. Start around 75 for photos, compare with the original at full size, and go lower until you can see a change.

Will Google index WebP and AVIF? #

Yes. Google lists both among the formats it supports for images.

Only if you overdo it. Google says sharp pictures tend to do better as thumbnails.

Should I compress SVG files? #

MDN notes SVG source can be compressed in transit or saved as .svgz. Removing editor junk from the file also helps.

Sources #

Updated 24 November 2026 by URSY.

Cite this page: Image compression. URSY. Updated 24 November 2026. https://ursy.com/wiki/image-compression/ · Section links

Tools for this

  • LiveImage SEO Checkeralt text, AVIF/WebP, sizes and licence markupRun the check →
  • LiveProduct Page Checkerschema, images, reviews, delivery info, AI readinessRun the check →
  • LiveAI Readiness Checkeris your site ready for ChatGPT, Gemini, Claude? Score + fixesRun the check →
  • LiveAI Bot Checkerwhich AI bots your robots.txt lets inRun the check →
  • LiveRobots.txt Checker + Generatortest any address against your rules, or write new onesRun the check →
  • LiveSchema Markup CheckerRun the check →
  • ProWhat AI readsAI reads of llms.txt, .md, .json, images, feedsIn URSY Pro →
  • ProImage SEO auditAlt text, sizes, formats, image sitemapsIn URSY Pro →
  • ProImage AI sidecars + licenceEach picture with a description file for AI and licence markupIn URSY Pro →

All 871 wiki entries, A to Z →