How to compress images for the web without visible quality loss

Why image weight matters, how lossy and lossless compression differ and which settings work for photos, screenshots and logos.

Images are usually the heaviest part of a web page. A single unoptimised photo from a modern phone can weigh 4-8 MB, while the same picture prepared for the web often looks identical at 150-300 KB. Smaller images load faster, use less mobile data, improve Core Web Vitals such as Largest Contentful Paint and make e-mail attachments easier to send.

Lossy versus lossless compression

Lossless compression rebuilds the original pixels exactly. PNG is lossless, and so is the optional lossless mode of WebP. It is the right choice for logos, icons, diagrams and screenshots with sharp text, where even tiny artefacts around edges are visible.

Lossy compression throws away detail that the human eye barely notices. JPEG, lossy WebP and AVIF work this way. Photographs contain smooth gradients and noise, so they compress extremely well: a quality setting between 70 and 85 usually removes more than half of the file size with no difference you can see at normal viewing size.

A practical workflow

  • Resize first. A photo that will be shown 800 pixels wide does not need to be 4000 pixels wide. Reducing the dimensions often saves more than any quality setting.
  • Pick the format by content: photos as JPEG or WebP, graphics with flat colours or transparency as PNG or WebP.
  • Compress with a quality of about 75-80, compare the result with the original at 100% zoom and only go lower if you cannot see a difference.
  • Keep the original. Lossy compression cannot be undone, so always store the untouched file somewhere safe.
  • Remove metadata such as camera model and GPS position when you publish a picture. It saves a few kilobytes and protects your privacy.

Common mistakes

Re-saving a JPEG many times stacks compression artefacts, so always compress from the original file. Upscaling a small image does not add detail, it only enlarges the file. And converting a screenshot with text to a low-quality JPEG creates blurry, noisy letters; use PNG or lossless WebP instead.

The image tools on this site work in your browser: the file you choose is processed on your own device and is not uploaded, so you can try different settings as often as you like.

How small should an image be?

There is no universal target, but useful budgets exist. A full-width hero photo on a website is usually acceptable at 150-300 KB, an image inside an article at 60-150 KB and a small product thumbnail at 15-40 KB. Those numbers are starting points rather than rules. A page with one large picture can afford more per image than a gallery with forty of them, because what the visitor experiences is the total weight and the time the largest visible element takes to appear.

Think about the display size as well. If a picture is shown 800 pixels wide, exporting it at 1600 pixels gives a sharp result on high-density phone and laptop screens. Going beyond twice the display width rarely produces a visible improvement and quickly doubles or triples the file.

Reading the quality slider correctly

The number on a quality slider is not a percentage of the original quality. A setting of 80 does not mean that 20% of the picture is lost, and the same number means different things in different encoders. JPEG 80, WebP 80 and AVIF 80 are not equivalent, so never compare formats by setting alone. Compare the pictures and the file sizes instead.

The relationship between quality and size is also not linear. Dropping from 100 to 85 often halves a JPEG with almost no visible change. Dropping from 60 to 40 saves far less and starts to show block patterns and colour smearing. Most photographs have a comfortable point somewhere between 70 and 85, and that is where it is worth stopping.

Where the damage shows first

Do not judge a compressed image only by looking at the whole picture. Zoom to 100% and inspect the areas that fail first:

  • Skies and other smooth gradients, where banding appears as visible stripes.
  • Text, logos and sharp edges, where a faint halo of noise forms around the shape.
  • Faces and skin, where too much compression removes natural texture and leaves a waxy look.
  • Dark shadows, where detail merges into coloured blocks.

If those four areas look fine, the rest of the image will almost always look fine too.

Compressing for e-mail and online forms

Web pages are not the only reason to reduce a file. E-mail providers commonly reject attachments above about 20-25 MB, and application forms often allow only a few hundred kilobytes or one or two megabytes per photo. When a form sets a strict limit, reduce the pixel dimensions first and then lower the quality in small steps. A portrait does not need to be 12 megapixels to be accepted, and resizing keeps it far cleaner than crushing a large file with an extremely low quality value.

A quick checklist before publishing

  • Is the width close to twice the width at which it will be displayed, or smaller?
  • Is the format suited to the content: photo or flat graphic?
  • Did you compress from the original instead of an already compressed copy?
  • Have you checked gradients, edges and faces at 100%?
  • Have you removed location data if the photo was taken somewhere private?
  • Is the descriptive file name something like red-bicycle.webp rather than IMG_4021.webp?

Each answer takes a few seconds to check, and together they prevent nearly all of the problems people run into with web images.

Tools mentioned in this guide