The Core of Web Image Optimization
If an image will be displayed at 800x600 pixels, do not upload a 4000x3000 pixel file. Resize it to the exact dimensions before uploading. Relying on the browser to shrink large images forces users to download unnecessary data.
The core trade-off: smaller files mean faster websites. Modern formats like AVIF and WebP reduce file sizes 40-60% compared to JPG without visible quality loss.
After resizing, convert and compress the image. A good workflow is to convert to AVIF with a quality setting around 70. This can reduce the original file size by 40-60% with little to no visible loss in quality.
| Format | Typical Size vs JPG | Best For | Key Trade-Off |
|---|---|---|---|
| AVIF | 40-60% smaller | Photographs, complex images | Newer format; fallback needed for older browsers |
| WebP | 25-35% smaller | Versatile use, transparency | Slightly less compression than AVIF |
| PNG | Larger than JPG | Logos, graphics with transparency | Much larger file sizes for photographs |
| JPG | Baseline | General photographs | No transparency support; can show artifacts |
For most photographic content, converting to AVIF or WebP provides the most significant file size reduction.
Choosing the Right Image Format
Your choice of image format has a significant impact on file size, quality, and browser compatibility. The content of the image itself—a detailed photograph or a simple logo—should guide your decision.
Modern Formats: AVIF and WebP
For nearly any photograph on the web, AVIF and WebP are the primary choices. They use advanced compression algorithms to reduce file sizes substantially compared to JPG while maintaining visual clarity.
Modern format options
- AVIF — Currently offers the highest compression efficiency, producing files often 40-60% smaller than a comparable JPG. Ideal for hero images and product shots where every kilobyte affects load time. Convert JPG to AVIF or PNG to AVIF.
- WebP — A reliable format with excellent browser support. Reduces file sizes by 25-35% compared to JPG. Supports both lossy and lossless compression, as well as transparency. Learn more in our JPEG vs WebP guide.
AVIF leverages technology from the AV1 video codec to achieve its small file sizes. In tests, AVIF files are often 20-50% smaller than WebP files at the same visual quality. With over 95% of users on supporting browsers, AVIF is becoming a standard.
When to Use Traditional Formats: JPG and PNG
Traditional formats still have specific use cases.
Traditional format roles
- JPG — Offers universal compatibility. Does not support transparency and uses lossy compression, which discards some image data to reduce file size. At high quality settings, this is not noticeable, but aggressive compression can introduce visual artifacts.
- PNG — The standard choice for images requiring a transparent background, such as logos and icons. Uses lossless compression, preserving every pixel of quality. The trade-off is significantly larger file sizes compared to JPG or WebP.
A practical comparison
Consider a large hero image for a landing page:
- Original PNG — 3.2 MB
- JPG (80% quality) — 450 KB
- WebP (similar quality) — 310 KB
- AVIF (similar quality) — 205 KB
Switching from JPG to AVIF reduced the file size by another 54%. This is a direct improvement to your page load speed and Largest Contentful Paint (LCP) score.
Mastering Compression and Resizing
Once you have selected a format, resizing and compression offer the largest performance gains. A common mistake is to upload a high-resolution image and resize it with CSS.
Never upload an image that is physically larger than its maximum display size. If a content column is 800px wide, do not use a 4000px wide image. This forces every visitor to download five times more data than needed.
Finding the Compression Sweet Spot
After resizing an image to its correct dimensions, the next step is compression. This involves a trade-off: you strategically remove some visual information in exchange for a smaller file. A "quality" slider in your optimization tool controls this balance.
For lossy formats like JPG, WebP, and AVIF, a quality setting between 60 and 75 is a good starting point. This often achieves a "visually lossless" state, where the file is much smaller, but the human eye cannot perceive a difference.
E-commerce product photo workflow
- Start with a 4.2 MB photo from a DSLR at 3000x2000 pixels
- Resize to display dimensions — Scale down to 800x533 pixels for the product page. This alone reduces the file to 750 KB.
- Convert and compress — Convert the resized image to AVIF at quality 70. Final file: 95 KB.
This workflow reduced the original file size by over 97%. This technical improvement directly impacts user experience and can influence conversion rates.
Further compression after conversion
After converting to a modern format like WebP or AVIF, you may want to compress further for optimal delivery. Compress.FAST's image compressor specializes in reducing file sizes without visible quality loss—similar to tools like TinyPNG, but with bulk processing and the same privacy guarantees.
Strip Unnecessary Metadata
Image metadata, or EXIF data, is another factor to consider. Cameras embed information like model, ISO, shutter speed, and GPS coordinates into photos. This data is unnecessary for web display and adds to the file size.
Most of this data should be removed to save a few kilobytes per image. Optimization tools like Convert.FAST handle this automatically.
Quick answers on compression
- Resizing vs compressing — Resizing changes dimensions (width and height in pixels). Compressing reduces file size by removing data, without changing dimensions.
- Will users notice quality loss? — Not if done correctly. A quality setting in the 60-75 range is a safe starting point, but always preview the result.
- Resize before or after? — Always resize first. Resizing discards unnecessary pixel data, giving the compression algorithm a smaller file to process.
Responsive Images and Lazy Loading
Serving desktop-sized images to mobile users creates a slow, frustrating experience. Responsive images solve this by allowing the browser to select the best-sized image from a set of options based on the user's screen.
Unoptimized images can account for over 50% of a page's total weight. This bloat negatively affects Core Web Vitals, particularly Largest Contentful Paint (LCP), pushing it beyond the recommended 2.5-second threshold and hurting SEO.
Using Srcset and Sizes
The srcset and sizes attributes are the standard for responsive images. They provide the browser with the information needed to download the most appropriate file.
<img
srcset="hero-image-480w.avif 480w,
hero-image-800w.avif 800w,
hero-image-1200w.avif 1200w"
sizes="(max-width: 600px) 100vw, 800px"
src="hero-image-800w.avif"
alt="A detailed description of the hero image content."
>How srcset works
- srcset — Lists the available image files and their intrinsic widths (e.g., hero-image-480w.avif is 480 pixels wide).
- sizes — Instructs the browser on the image's display size. "If the screen is 600px or less, the image fills 100% of the viewport width. Otherwise, it's 800px wide."
- src — A fallback for older browsers that do not support srcset.
Adding Native Lazy Loading
Even correctly sized images should not all load at once. Lazy loading defers the download of off-screen images until they are about to scroll into view.
<img src="your-image.avif" loading="lazy" alt="Description.">Adding loading="lazy" tells the browser to wait, which can significantly speed up the initial page load by prioritizing visible content. This native attribute is one of the simplest and most effective performance improvements available.
Prioritizing Critical Images
Lazy loading is not appropriate for critical images at the top of the page, such as a logo or main banner. These are often the LCP element, and delaying them would harm performance.
LCP image optimization
- For the main LCP image — Use
fetchpriority="high"and do not useloading="lazy". - For all other off-screen images — Use
loading="lazy".
Automating Your Optimization Workflow
Optimizing images manually is not practical for large quantities. An automated workflow is essential for handling tasks like processing a product catalog or preparing images for a marketing campaign.
Scripting with Command-Line Tools
For developers comfortable with the terminal, command-line tools like ImageMagick and FFmpeg offer powerful automation capabilities. A simple script can process an entire folder, resizing images, converting formats, and stripping metadata.
Using Cloud-Based Services for Bulk Processing
Cloud-based services offer a simpler alternative for teams. Platforms like Convert.FAST are designed to process large batches of files without requiring code. Upload hundreds of source files (PNG, HEIC, RAW) and apply a consistent optimization profile to the entire batch. The service processes the files and provides a single ZIP file containing the optimized images.
The Convert + Compress workflow
For optimal web performance, use a two-step approach:
- Step 1: Convert — Use Convert.FAST to change formats (e.g., PNG to WebP, HEIC to AVIF)
- Step 2: Compress — Use Compress.FAST to reduce file size further without quality loss
To understand how these steps are connected, you can review how a conversion pipeline is structured. Learn more about batch processing.
Security and Privacy in Automation
When using a third-party service, security and privacy are important considerations. Choose a service that is transparent about its data protection practices.
| Feature | Why It Matters |
|---|---|
| TLS 1.3 Encryption | Secures files during upload and download |
| AES-256 at Rest | Protects files while stored on the server |
| EU Data Residency | Data handled under GDPR protections |
| Auto-Delete Policy | Files don't linger on third-party servers |
Files are encrypted in transit and at rest, processed on EU servers, and automatically deleted within one hour.
SEO and Accessibility
Optimizing file size is only part of the process. You also need to ensure that search engines and all users can understand your images.
Start with a descriptive filename. A filename like IMG_8821.JPG provides no context to search engines. Renaming it to blue-nike-running-shoe.avif gives them useful information.
Why ALT Text is Non-Negotiable
ALT text (alternative text) is a short description in the image's HTML tag. It serves two purposes. First, it is an accessibility feature. Screen readers announce this text to visually impaired users, providing them with the same context as sighted users.
Second, it is an SEO signal. It gives search crawlers another clue about the image's content, which can help with ranking in image searches.
Writing good ALT text
- Bad — alt="shoe"
- Good — alt="A blue Nike running shoe with white laces on a gray background."
The second example provides a clear picture for both users and search engines.
Speeding Up Delivery with a CDN
A Content Delivery Network (CDN) is the final step in delivering optimized images quickly. A CDN is a distributed network of servers that stores copies of your images closer to your visitors.
If your main server is in Los Angeles, a visitor from London would experience latency as data crosses the Atlantic. With a CDN, that user would instead retrieve the image from a local server in Europe. This reduces latency, improves p50 and p95 load time metrics, and provides a faster experience for a global audience.
Frequently Asked Questions
Should I use AVIF or WebP?
AVIF is the high-performance option. Use it if you need the smallest possible file sizes for complex photographs and your users are on modern browsers.
WebP is a reliable, all-around choice. It provides significant size reduction over JPG, supports transparency, and has near-universal browser compatibility.
For a robust solution, use the <picture> HTML element to serve AVIF to supporting browsers while providing a WebP or JPG fallback for others.
What is the best compression quality setting?
There is no single "magic number," but a good starting point for lossy formats (JPG, WebP, AVIF) is a quality setting between 60 and 75. This range typically reduces file size significantly without a noticeable drop in visual quality.
The ideal setting varies by image. An image with flat colors may look fine at quality 50, while a detailed portrait might need to be closer to 80. Always preview the compressed image.
How does image optimization help SEO?
Speed: Smaller images lead to faster page loads. Site speed is a ranking factor for Google, particularly with its focus on Core Web Vitals. A faster site provides a better user experience, which search engines reward.
Context: Proper optimization helps search engines understand your images. Descriptive filenames (e.g., black-labrador-retriever-playing-fetch.jpg) and meaningful ALT text provide crucial context. This helps your images rank in image search results.
Convert.FAST lets you batch convert up to 1,000 images at once—from HEIC, PNG, or JPG to modern formats like WebP and AVIF. Files are encrypted and auto-deleted within one hour.
Related Topics

Stewart Celani
Founder
15+ years in enterprise infrastructure and web development. Stewart built Tools.FAST after repeatedly hitting the same problem at work: bulk file processing felt either slow, unreliable, or unsafe. Convert.FAST is the tool he wished existed—now available for anyone who needs to get through real workloads, quickly and safely.
Read more about Stewart