PhotoToolsPhotoTools
Home/Blog/How to Compress Images for a Website Without Ruining Quality

How to Compress Images for a Website Without Ruining Quality

Compressing website images without visible quality loss means matching the file to its real job: the display size, device pixel ratio, image format, compression level, and whether it is an LCP hero, product photo, screenshot, thumbnail, or background image. This guide gives practical settings and a repeatable review workflow.

By PhotoTools Editorial Team · Updated July 18, 2026

Reviewed July 18, 2026 against PhotoTools compress and resize behavior, MDN canvas export documentation, Google WebP documentation, Chrome image-delivery guidance, and web.dev image performance guidance.

Compress images privately in your browser

Free · No upload · Runs in your browser

The practical answer

To compress website images without ruining quality, do not start by dragging a quality slider to the lowest number that looks acceptable. Start with the image's real job on the page. A hero image, product zoom photo, blog illustration, avatar, screenshot, and background texture all need different dimensions, formats, and quality settings.

The useful rule is: resize to the largest displayed size first, then compress just enough that the image still looks unchanged in the layout. If a blog image displays at 760 CSS pixels wide, a 1500-1600 px source is usually plenty for high-density screens. A 5000 px camera original is wasted data. A 760 px export may look soft on retina screens. The right file sits between those extremes.

"Without losing quality" also needs a plain definition. For website work, it usually means no visible quality loss at the size visitors actually see, not mathematical pixel perfection. A compressed WebP is not identical to the original file, but it can be visually indistinguishable in the page.

Decide what kind of website image it is

Before choosing WebP, AVIF, JPEG, PNG, or a quality value, classify the asset:

Image role Typical display size Good first format Starting quality Review closely
LCP hero image 1200-2400 px wide AVIF with WebP/JPEG fallback AVIF 45-65, WebP 78-85 Sky, skin, shadows, brand colors
Blog/content image 1200-1600 px wide source WebP, JPEG fallback WebP 78-85 Fine detail and gradients
Product grid thumbnail 500-900 px wide source WebP WebP 70-78 Labels, edges, texture
Product detail image 1200-2000 px wide source WebP or AVIF WebP 82-88, AVIF 50-70 Zoom detail and color accuracy
UI screenshot Exact display size or 2x PNG or lossless WebP Lossless when text matters Text, icons, hard edges
Logo or icon Vector if possible SVG Not applicable Clean scaling
Background texture Display size only WebP or JPEG 60-75 Banding and seams

This table is deliberately opinionated. Most bad website-image compression comes from treating every asset the same way. A homepage hero can affect Largest Contentful Paint. A product detail image may affect trust and conversion. A decorative background can be much smaller because nobody studies it.

Resize first: dimensions do most of the work

Compression lowers the number of bytes used to store a fixed pixel grid. Resizing changes the pixel grid itself. If the source has far more pixels than the page can display, resizing is the cleaner win.

Use this simple sizing formula:

target source width = largest CSS display width x device pixel ratio

For example:

  • A card image displayed at 320 CSS px should have a 640 px source for 2x screens.
  • A blog image displayed at 760 CSS px should have a 1500-1600 px source.
  • A full-width hero displayed near 1200 CSS px may need a 2000-2400 px source, depending on crop and audience devices.

Do not blindly use 3x for every image. web.dev notes that DPR and layout both matter, and in many cases users cannot perceive the benefit of very high DPR sources. A 2400 px hero can be sensible. A 5000 px hero because "more pixels is safer" usually just burns bandwidth.

PhotoTools separates these jobs. Use Resize when you need exact pixels or a smaller long edge. Then use Compress to choose JPEG, WebP, or AVIF and tune the quality.

Choose the format before touching quality

The format decides what kind of detail can be removed cleanly.

  • Use WebP for most website photos. It is broadly supported in modern browsers and usually smaller than JPEG at similar visible quality. Google's WebP documentation reports 25-34% savings versus comparable JPEG images at equivalent quality.
  • Use AVIF where every byte matters. AVIF can beat WebP on large photographic assets, but it can be slower to encode and adds pipeline complexity. Use it with fallbacks, not as the only file.
  • Use JPEG as the compatibility fallback. It is still useful for email, older CMS workflows, downloads, and fallback <img> sources.
  • Use PNG or lossless WebP for screenshots and text. Lossy JPEG/WebP can make small UI text fuzzy and add color noise around hard edges.
  • Use SVG for logos and icons. A raster logo converted to WebP may be smaller than PNG, but a clean SVG is usually sharper and lighter.

If you use <picture>, put the most efficient format first and keep a compatible fallback in the nested img:

<picture>
  <source
    type="image/avif"
    srcset="/images/hero-1200.avif 1200w, /images/hero-2000.avif 2000w"
    sizes="100vw"
  />
  <source
    type="image/webp"
    srcset="/images/hero-1200.webp 1200w, /images/hero-2000.webp 2000w"
    sizes="100vw"
  />
  <img
    src="/images/hero-1200.jpg"
    width="1200"
    height="800"
    alt="A finished kitchen remodel with walnut cabinets and natural light"
  />
</picture>

The img element still matters. It carries the fallback source, alt, width, and height. Do not hide accessibility or layout information in source elements.

Quality settings that are useful in practice

Quality numbers are not standardized. JPEG quality 80 in one encoder is not guaranteed to match quality 80 in another encoder. WebP 80, JPEG 80, and AVIF 50 are also not equivalent. Treat quality as a starting point, then inspect the exported file.

Output Start at Move up when Move down when
JPEG fallback 82-88 Product detail, faces, text over photo Decorative photo, background, file still too heavy
WebP photo 78-85 Hero, product, portfolio image Thumbnail, grid, simple background
WebP thumbnail 70-78 Labels or texture look soft File is still heavy and image is small
AVIF photo 45-65 Banding, skin tones, fabric, fine detail suffer Large hero is still too heavy
PNG No lossy quality Screenshot or transparent asset needs exact edges Consider WebP/AVIF only if destination supports it

A common trap is exporting every image at quality 95 or 100 because it feels safer. For most web photos, the extra bytes are visible in the network waterfall, not on the page. Another trap is forcing quality below 50 to hit an arbitrary target. If quality has to go that low, resize the image or switch formats before degrading it further.

Target file sizes by page role

These are not Google rules or magic ranking thresholds. They are practical review targets that help catch images that are obviously too heavy.

Asset Healthy working target Notes
Avatar or author headshot 10-40KB Usually 160-400 px displayed
Card thumbnail 15-60KB Grid images should be consistent dimensions
Blog content image 60-180KB Depends on width and image detail
Product grid image 50-150KB Keep labels readable
Product detail image 120-300KB Allow more for zoom and texture
Above-the-fold hero 150-450KB Larger may be justified, but test LCP
Fullscreen portfolio photo 250-700KB Quality can matter more than strict size
UI screenshot 30-250KB Text clarity matters more than smallest bytes

If a 760 px blog image is 900KB, it probably needs attention. If a full-width portfolio image is 410KB and looks excellent, shrinking it to 90KB may be the wrong goal.

Compressing LCP and hero images

The image most worth optimizing is often the largest above-the-fold image. In Core Web Vitals language, this is frequently the Largest Contentful Paint image. Compressing it can help, but only if the image is also discovered and loaded early.

For a hero image:

  1. Crop it to the real aspect ratio used on the page.
  2. Export responsive widths, such as 1200 px and 2000 px.
  3. Use AVIF first and WebP/JPEG fallback if your stack supports it.
  4. Do not lazy-load the hero or other above-the-fold LCP candidate.
  5. Add width and height so the browser can reserve layout space.
  6. Use fetchpriority="high" only for the single image most likely to be the LCP element.

Example fallback img:

<img
  src="/images/hero-1200.jpg"
  srcset="/images/hero-1200.jpg 1200w, /images/hero-2000.jpg 2000w"
  sizes="100vw"
  width="1200"
  height="800"
  fetchpriority="high"
  alt="A finished kitchen remodel with walnut cabinets and natural light"
/>

Do not use fetchpriority="high" on a whole gallery. Priority hints are sharp tools; use one for the image that actually needs to arrive first.

How to compare compression results

The right comparison is not original file versus compressed file at 100% zoom. That is how you talk yourself into shipping oversized images. Compare at the size and context visitors see.

Use this review pass:

  1. Put the compressed image in the actual page or a same-width test layout.
  2. View it at desktop and mobile widths.
  3. Check the likely danger zones: faces, skin, sky, gradients, fabric, product labels, small text, and high-contrast edges.
  4. Toggle between original and compressed versions at the rendered size.
  5. Briefly zoom to 100% only to catch obvious artifacts, not to demand perfection nobody will see.

Compression artifacts have personalities. JPEG often shows blocky edges, ringing, or color noise. Over-compressed WebP can smear texture. AVIF can produce banding or plasticky detail if pushed too far. PNG screenshots usually fail in the opposite direction: they look perfect but weigh much more than necessary.

A PhotoTools workflow for website images

PhotoTools is useful before an image reaches your CMS, CDN, or repository. It does not replace a full build pipeline, but it gives you a clean manual workflow for small sites, blog posts, client previews, and one-off assets.

  1. Keep the original source file untouched.
  2. Decide the image role: hero, content image, product photo, screenshot, thumbnail, or background.
  3. Use Resize first when the original is much larger than the display size.
  4. Open Compress, choose JPEG, WebP, or AVIF, and start near quality 80 for WebP/JPEG.
  5. Click Compress all and read each card's original size, output size, and percentage saved.
  6. Download the result and inspect it in the page context.
  7. If it fails visually, go back to the original or resized copy and export again at a higher quality.
  8. If it is still too heavy, reduce dimensions before lowering quality into artifact territory.

Do not keep recompressing the already-compressed download. That compounds lossy artifacts. Go back to the master or the clean resized intermediate.

Metadata and privacy

Camera files often contain EXIF metadata: GPS coordinates, capture date, camera model, lens, and editing software. That metadata does not help website visitors see the image. It can also expose private information.

PhotoTools compresses images by decoding the file, drawing the pixels to a browser canvas, and exporting a new file. MDN documents that OffscreenCanvas.convertToBlob() can specify image type and quality for formats that support lossy compression. Because the output is generated from canvas pixels, camera metadata is usually not copied into the new file.

For sensitive photos, verify the final download with a metadata checker before publishing. Privacy is not just file size.

Common mistakes that make images look bad

  • Compressing before resizing: You are trying to save bytes from pixels the layout will never show.
  • Using PNG for photos: PNG is usually huge for camera images.
  • Using JPEG for screenshots with text: The file may be smaller, but the text can look fuzzy.
  • Judging at the wrong size: Full-resolution zoom makes harmless artifacts look dramatic.
  • Exporting one giant hero for all devices: Mobile visitors download desktop pixels they cannot use.
  • Lazy-loading the hero: Below-the-fold images can be lazy-loaded. The LCP image should not be.
  • No width and height: The page may shift as images load.
  • Recompressing the published file: Start from the source when possible.

A compact publishing checklist

Before uploading a website image, run through this:

  1. Is this the right format for the content type?
  2. Is the source width based on real display width and likely DPR?
  3. Is there a smaller mobile candidate if the hero crop changes on mobile?
  4. Is the quality setting high enough for faces, labels, gradients, and product detail?
  5. Is the file size reasonable for its role?
  6. Does the page include width, height, useful alt, and responsive srcset/sizes when needed?
  7. Is the LCP image eager and prioritized, while below-the-fold images are lazy-loaded?
  8. Did you check the exported image in the actual layout?
  9. Did you keep the original source file?

The best compression workflow is boring in the right way: choose the right pixels, choose the right format, export at a sensible quality, inspect the real page, and stop before the image starts to look processed.

Technical sources checked

This article was reviewed against the current PhotoTools compression and resize implementation, web.dev's image performance guide, Chrome's Improve image delivery insight, Chrome's properly size images guidance, MDN's OffscreenCanvas convertToBlob() documentation, MDN's image file type guide, and Google's WebP documentation.

Frequently asked questions

How do I compress images for a website without losing quality?

Resize the image to the largest size it will actually display, export in the right format, start near quality 80 for WebP or JPEG, then compare the result at the rendered page size. Stop when the image looks the same in the layout, not when the file is as tiny as possible.

What is the best compression quality for web images?

Use 78-85 for most WebP photos, 80-88 for JPEG fallbacks, 70-78 for thumbnails, and 45-65 as a starting range for AVIF. Encoder numbers are not universal, so judge the exported image visually.

Should I resize or compress images for the web first?

Resize first, then compress. Resizing removes unnecessary pixels; compression stores the remaining pixels more efficiently. A well-sized image at moderate quality usually beats a huge image crushed to low quality.

Is WebP or JPEG better for website images?

WebP is usually the better delivery format for modern websites because it often produces smaller files and can support transparency. Keep JPEG as a fallback for email, older tools, and third-party systems that reject WebP.

Should I use AVIF for every website image?

No. AVIF is useful for large heroes, galleries, and high-traffic pages where byte savings matter and you can serve WebP or JPEG fallbacks. For tiny thumbnails or simple teams, WebP may be simpler.

What file size should a website image be?

As working targets: small thumbnails 15-40KB, article images 60-180KB, product grid images 50-150KB, product detail images 120-300KB, and hero images 150-450KB. Detailed images may need more.

Why do compressed website images look blurry?

Usually the image was resized too small, uploaded below the display slot, judged at 100% zoom instead of rendered size, or exported at very low JPEG/WebP quality. Check dimensions before lowering quality further.

Does compressing images help SEO?

Indirectly. Smaller, correctly sized images can reduce download time and improve Largest Contentful Paint, but image SEO still needs useful page content, alt text, dimensions, and relevant visuals.

Does browser compression remove EXIF metadata?

Canvas-based export usually creates a new image from pixels and does not copy camera metadata such as GPS, camera model, and timestamps. Verify the final file when privacy matters.

Can I compress images that are already published?

Yes, but start from the original source if you can. Downloading an already compressed website image and compressing it again can compound artifacts. Re-export from the master file, then replace the published asset.

Keep reading