DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
AVIF

How to Compress Images for the Web Without Sacrificing Quality

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To compress images for the web, first resize each image to the largest dimensions it will actually appear at, then test an appropriate format and compression level at the rendered size. Use responsive image markup so phones do not download desktop-sized files, and keep a fallback when browser or workflow compatibility calls for one. There is no universal quality setting: compare the visual result and file size for each image.

Start by resizing images to the size the page needs

Do not begin by choosing a codec. If a page displays an image in a 600-pixel-wide slot, uploading a 4,000-pixel-wide original means the browser may download many pixels the visitor will never see. Create an output no larger than the largest rendered slot you need, then make a small set of widths for responsive layouts. The right maximum depends on your design and display density; there is no single dimension that fits every site.

Use srcset to list available image widths and sizes to describe the rendered slot. The browser can then select a suitable candidate for the viewport instead of always downloading the largest file. See web.dev’s image guidance for responsive delivery and format examples.

<img
  src="/images/product-800.jpg"
  srcset="/images/product-400.jpg 400w,
          /images/product-800.jpg 800w,
          /images/product-1200.jpg 1200w"
  sizes="(max-width: 600px) 100vw, 600px"
  alt="A product shown on a desk"
>

In this example, the layout uses the full viewport width up to 600 pixels and a 600-pixel slot on wider screens. Adjust sizes to match your actual CSS; a misleading value can make the browser choose an image that is too small or unnecessarily large. Provide a meaningful alt description appropriate to the image’s purpose.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Nero AI Image Upscaler 365 | Enlarge Images & Sharpen Photos | AI Upscaling to 4K | Fix Blurry & Low-Resolution Pictures | Easy Photo Optimization | 1 PC | Windows 11/10
  • ✔️ AI Upscaling up to 8K: Enlarge small, low-resolution, or old photos with crisp details, clean edges, and fewer artifacts — perfect for prints, social media, blogs, and online galleries.
  • ✔️ Fix blurry or noisy photos: AI restores clarity by enhancing textures, sharpening faces, hair, and fine details while reducing noise and JPEG compression errors.
  • ✔️ Ideal for family photos, scans & mobile images: Improve pictures from smartphones, tablets, digital cameras, scanners, and old archives with professional-quality results.
  • ✔️ Fast & easy 1-click enhancement: Batch-process multiple photos at once and improve image quality instantly — no editing experience required.
  • ✔️ Reliable results & broad file support: Works with JPG, PNG, TIFF and more — stable AI processing even on old, compressed or damaged photos.

Choose lossy or lossless compression based on the image

Lossy compression for photographs

Lossy encoding removes some image information to reduce file size. It is often an effective choice for photographs, where modest changes may be hard to notice at the size shown on the page. The trade-off is that too much compression can make skin look waxy, introduce blocks or ringing around edges, or damage fine texture.

Lossless compression when exact pixels matter

Lossless encoding preserves image data, which can matter for sharp-edged graphics, exact pixel art, transparency, or text-like detail. Lossless files can be larger than lossy alternatives, so use this mode when fidelity matters rather than assuming it is always the best web choice. MDN describes the distinction between lossy and lossless compression in its image format guide.

Pick the format that suits the content

Compare formats on the actual image, at an equivalent visual quality, rather than choosing by format name alone. For photographs, test JPEG, lossy WebP, and AVIF. For graphics that need crisp edges or transparency, compare PNG with lossless WebP or AVIF. WebP supports transparency; AVIF can produce smaller files, but compatibility and workflow needs can make a fallback useful. Neither format is guaranteed to be smallest for every image.

Format Useful starting point Trade-offs to check
JPEG Photographs and other continuous-tone images Compare its size and appearance with lossy WebP and AVIF at the same display size.
WebP Photographs or graphics, including images needing transparency Test lossy and lossless modes as appropriate; inspect the result rather than assuming conversion preserves the original exactly.
AVIF Photographs and graphics where modern encoding is suitable It can be smaller, but verify browser and workflow compatibility and provide a fallback where needed.
PNG Graphics where sharp detail or lossless output is important For suitable images, compare with lossless modern formats; do not convert to a lossy format if artifacts are unacceptable.

There is no universal setting suitable for all cases. Image content, encoder behavior, quality target, decode and encode cost, support requirements, and fallback complexity all affect the choice. Guidance from web.dev and MDN supports testing formats against the image rather than promising a fixed saving.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Offer modern formats with a fallback

A <picture> element lets you offer AVIF first, WebP next, and a JPEG or PNG fallback. The browser selects the first source it can render. The fallback should match the content and preserve any important transparency or visual detail.

<picture>
  <source type="image/avif" srcset="/images/landscape.avif">
  <source type="image/webp" srcset="/images/landscape.webp">
  <img src="/images/landscape.jpg" alt="A landscape at sunset">
</picture>

If your server selects an image format based on the request’s Accept header instead, configure caches correctly: responses that vary by that header should include Vary: Accept. Without appropriate cache variation, a cache may serve a representation selected for one request to a client that sent a different header. Read web.dev’s format-serving guidance for this approach.

How to compress an image and judge the result

  1. Identify the real display slot. Check the largest width and height at which the image appears, including responsive layouts. Do not use the original camera dimensions by default.
  2. Resize and make responsive variants. Export a small set of useful widths and wire them up with accurate srcset and sizes values.
  3. Choose a candidate format. For a photo, compare JPEG, lossy WebP, and AVIF. For a graphic requiring exact edges or transparency, test PNG and lossless modern formats.
  4. Export several quality levels. There is no reliable one-size-fits-all quality number. Compare output sizes and inspect the images side by side.
  5. Inspect at the rendered size. Check faces, text, edges, gradients, texture, and transparent areas. Zoom in when needed to find artifacts, but decide based on how the image will actually be used.
  6. Serve a fallback where needed. Use <picture> for format alternatives or configure content negotiation and its cache variation correctly.
  7. Measure the page after deployment. Confirm which variant is requested and consider image effects on real loading experience. Images can be candidates for Largest Contentful Paint (LCP), so efficient encoding may improve perceived loading; the actual effect depends on the page.

Tools and workflows

For a few images, an editor or a conversion tool lets you export multiple candidates and visually compare them. MDN identifies Squoosh as an online tool for converting images to AVIF. web.dev also names Squoosh and ImageOptim, and discusses image optimization services and CDNs for generating or delivering variants. Check a tool’s current features, privacy terms, and commercial terms before relying on it; availability and terms can change.

For a large library or frequently changing content, automated image optimization can reduce manual export work by producing resized and format-specific variants. Evaluate whether the workflow preserves required image details, supports the formats and fallbacks your site needs, and fits your privacy and delivery requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your task is to capture a page as an image while checking how it renders, ScreenshotNeo is a website screenshot API and MCP server; it does not replace image compression for assets you publish. Its capture options include PNG, JPEG, or WebP output, but you should still resize and optimize website images using the workflow above. For a capture request, one GET call can return a screenshot; the API also supports PDF output.

For developers who want to capture a rendered page, the request can be made with cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request parameters and response details. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses indicate the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo to try the free monthly allowance.

Common compression problems and fixes

The file is still too large

Check dimensions first: an oversized source may outweigh the benefit of changing formats. Then compare formats and adjust lossy quality gradually while inspecting the result. For a responsive page, make sure the mobile layout is not downloading the largest candidate unnecessarily.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The compressed image looks blurry or damaged

Reduce the strength of lossy compression, try another encoder or format, or use lossless output if exact detail is necessary. Inspect text, faces, gradients, and fine edges; artifacts often appear in these areas before they are obvious elsewhere.

Transparency or sharp edges were lost

Use an output mode and format that supports the image’s transparency and fidelity needs. WebP supports transparency; test lossless WebP or AVIF against PNG for graphics, and verify the exported file retains the required alpha channel.

A browser or cache serves the wrong variant

Check the <picture> source order, declared MIME types, and fallback path. If the server chooses a representation from the Accept header, ensure its cache behavior varies on that header and that the corresponding Vary: Accept response header is present.

The image downloads but page loading does not improve

Verify the actual file and dimensions requested in the browser’s network panel, then measure page performance under the conditions that matter to your visitors. Image encoding is only one factor in loading; the page’s layout and other resources also affect when content appears.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to measure before calling the job done

  • Dimensions: Is each candidate sized for a real rendered slot rather than the original source?
  • Bytes and visual quality: Which export is smallest while remaining acceptable at display size?
  • Responsive selection: Does the browser request an appropriate srcset candidate at phone and desktop widths?
  • Compatibility: Does each target browser have a supported source or a suitable fallback?
  • Page performance: Does the page’s measured loading behavior improve after deployment?

There is no defensible universal percentage saving: the result varies with the source images, dimensions, encoder, and visual quality target. Test a representative set of your own images before estimating savings across a site.

Best Value
Scrivar PDF Pro - Organize, Edit, Compress, Convert, Merge, eSign, OCR & 30+ tools | Lifetime License
  • EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
  • PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
  • UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
  • PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
  • OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.

Frequently Asked Questions

Should I compress an image before or after resizing it?

Resize it for the largest rendered slot first, then compare compression settings on that output.

Is WebP always smaller than JPEG or PNG?

No. The result varies by image and encoding mode, so compare file size at an acceptable visual quality.

Does converting an image to AVIF guarantee that it remains lossless?

No. Losslessness depends on the encoding mode; inspect and verify the output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.