How to Compress Images for Your Website Without Visible Quality Loss

By the Img Hut team · Published

Images are usually the heaviest part of a web page, and the largest image near the top of the page is often the element that search engines’ page-experience measurements treat as the main content, the Largest Contentful Paint. Making images lighter is therefore one of the most effective speed improvements you can make. The goal is not the smallest possible file but the smallest file in which a visitor cannot see a difference at normal viewing size. This workflow gets you there in five steps.

Step 1: Resize to the size the image is actually displayed

The biggest savings come from pixel dimensions, not from quality settings. A 12-megapixel phone photo is 4032 × 3024 pixels. If your blog’s content column is 800 pixels wide, even a high-density screen showing two device pixels per CSS pixel needs only about 1600 pixels of width. Resizing that photo to 1600 × 1200 removes about 84% of its pixels before you touch the quality slider, and the file shrinks accordingly.

To find the display size, right-click the image on your live page, choose Inspect, and look at the rendered width in the browser’s developer tools, or check your theme’s documentation. Then aim for roughly twice that width:

Where the image appearsTypical display widthWidth to export
Full-width hero or bannerThe full browser window1600–2400 px, ideally in several sizes
Image inside an article column600–800 px1200–1600 px
Cards, thumbnails and grids200–400 px400–800 px
Logos and iconsSmallSVG if possible, otherwise twice the displayed size

Use Resize Image with the aspect ratio locked, and only enter the width. If the image also needs a different shape, crop it first with Crop Image.

Step 2: Choose the format

Photographs belong in WebP or JPEG. Screenshots, diagrams and graphics with text belong in PNG, or in lossless or high-quality WebP. Anything that needs a transparent background must be PNG or WebP. If you are unsure, our guide JPG vs PNG vs WebP walks through the decision.

Many content management systems, image CDNs and hosting platforms can resize images and create WebP versions automatically. If yours does, upload a well-sized, high-quality JPEG or PNG and let it generate the variants; compressing heavily beforehand only stacks two rounds of loss on top of each other.

Step 3: Pick a quality setting, then check it

For lossy formats, start at 80 for JPEG and around 75–80 for WebP. Then compare the result with the original side by side at 100% zoom, which is what Compress Image shows you. Lower the setting in steps of about five until you can see a difference, then go back one step. Small thumbnails often look fine at 60–70; large hero images and product photos that sell something deserve 80–90.

Knowing what to look for makes the check fast:

Quality numbers are not comparable between programs. “80” in a browser, in Photoshop and in an online service are different amounts of compression, so judge by eye, not by the number. As very rough orientation, many sites try to keep large hero images to a few hundred kilobytes and ordinary in-article images well below that. These are rules of thumb, not limits: a detailed photo may need more, a simple one far less.

Step 4: Remove what you do not need

Photos from cameras and phones carry EXIF metadata: camera model, settings and often the GPS coordinates of where the picture was taken. On a public website that information is rarely useful and can be a privacy problem. Img Hut’s tools re-encode images through a canvas, so their output contains no EXIF data. For the same reason, embedded color profiles are dropped and colors are handled in the standard sRGB space; photos captured in a wide-gamut space such as Display P3 may look very slightly less saturated afterwards, which is rarely noticeable on the web.

Step 5: Serve the images well

A well-compressed file can still slow a page down if the HTML around it is careless. A few attributes make a large difference:

For example, an article image offered in two widths:

<img src="/images/team-1600.webp"
     srcset="/images/team-800.webp 800w, /images/team-1600.webp 1600w"
     sizes="(max-width: 840px) 100vw, 800px"
     width="1600" height="1067"
     alt="Our support team at the office"
     loading="lazy">

If you still need to support very old browsers without WebP, wrap the image in a <picture> element with a WebP <source> and a JPEG fallback in the <img>.

Putting it together: one photo, start to finish

Suppose you want to add a 4032 × 3024 phone photo to an article with an 800-pixel column. Resize it to 1600 × 1200, which removes about 84% of the pixels. Compress the resized copy to WebP at quality 80 and compare it with the original at full size, paying attention to faces and to any sky. If it looks identical, try 75; if you notice smudging, go back to 80 or 85. Export an 800-pixel version as well for small screens, then add both to the page with srcset, width, height and loading="lazy". The whole process takes a couple of minutes and the page carries a small fraction of the original photo’s weight.

Common mistakes to avoid

Quick checklist

  1. Crop to the right shape, if needed.
  2. Resize to about twice the displayed width.
  3. Pick WebP or JPEG for photos, PNG or WebP for graphics.
  4. Start at quality 80, compare at 100% zoom, adjust in steps of five.
  5. Add width, height, srcset and, below the fold, loading="lazy".

Tools mentioned in this guide

More guides