Image Guides

A Practical Guide to Image Sizing for Website Performance

From pixel dimensions to responsive srcset—practical techniques for sizing images that load fast and look sharp.

Stewart Celani Created Jan 23, 2026 10 min read

Quick answer: For optimal website performance, size hero images to a maximum of 1920px wide, content images to 800-1200px, and thumbnails to 300-500px. Target file sizes under 200KB for heroes and under 100KB for content images. Use responsive srcset attributes to serve appropriately sized images to different devices.

Ready to optimize your images now? Compress up to 50 files free, or up to 1,000 on paid plans:

Open image compressor

Why Image Sizing Is a Performance Priority

Images are typically the largest files on any web page, often accounting for 50-80% of total page weight. When images are sized incorrectly—either too large in pixel dimensions or poorly compressed—they become the primary bottleneck for page load times.

A single oversized image can add seconds to your page load time. This affects user experience directly: research consistently shows that pages taking more than 3 seconds to load lose over half their mobile visitors. For e-commerce sites, every additional second of load time can reduce conversions by 7%.

The Core Web Vitals Connection

Google uses Core Web Vitals as a ranking signal, and images directly impact these metrics:

  • Largest Contentful Paint (LCP) — The main image on your page is often the LCP element. An oversized hero image will cause a poor LCP score, directly affecting SEO rankings. Target: under 2.5 seconds.
  • Cumulative Layout Shift (CLS) — Images without defined width and height attributes cause layout shifts as they load, creating a jarring user experience. Target: under 0.1.
  • Total Page Weight — Google recommends keeping total page size under 1.5 MB for mobile users. Images should stay well under half this budget.

Image Type Recommendations

Image TypeMax Width (px)Target File SizeNotes
Hero/Banner1920Under 200 KBFull-width images; consider 2560px for 4K displays
Content Images800-1200Under 100 KBIn-article images; match container width
Thumbnails300-500Under 30 KBGrid views, cards, previews
Icons/Logos100-200Under 10 KBConsider SVG for logos

Understanding Digital Image Fundamentals

Before diving into optimization techniques, understanding the basics of digital images helps you make informed decisions about sizing and compression.

Pixels vs. Display Size

A pixel is the smallest unit of a digital image. When we say an image is "1920x1080 pixels," that's its intrinsic size—the actual data it contains. The display size is how large the image appears on screen, controlled by CSS or HTML attributes.

The relationship between these two determines whether your image appears sharp or blurry. An image displayed larger than its pixel dimensions will appear soft. An image displayed smaller than its pixel dimensions wastes bandwidth—the browser downloads data it immediately discards.

The DPI Myth

DPI Doesn't Matter for Web

DPI (dots per inch) and PPI (pixels per inch) only matter for print. Web browsers completely ignore these settings—they only care about pixel dimensions. A 1000x1000 image at 72 DPI renders identically to a 1000x1000 image at 300 DPI. Both are simply 1000x1000 pixels.

Don't waste time changing DPI settings for web images. Focus on pixel dimensions and file size instead.

Aspect Ratio and Cropping

Aspect ratio is the proportional relationship between width and height. Common ratios include 16:9 (widescreen), 4:3 (traditional), 1:1 (square), and 3:2 (photography). Maintaining consistent aspect ratios across your site creates visual harmony and simplifies responsive design.

When resizing images, decide whether to crop to fit a target ratio or letterbox to preserve the original. For most web use, cropping to a consistent ratio provides the cleanest results.

Raster vs. Vector

TypeFormatsBest ForScaling
RasterJPG, PNG, WebP, AVIFPhotos, complex imageryQuality degrades when enlarged
VectorSVGLogos, icons, illustrationsInfinitely scalable without quality loss

For logos and icons, use SVG whenever possible. Vector graphics remain crisp at any size and typically have smaller file sizes than raster equivalents for simple shapes.

Choosing the Right Image Format

The format you choose affects both file size and quality. Modern formats offer significant compression improvements over legacy options, but browser support varies.

JPG (JPEG)

JPG remains the workhorse format for photographs and images with complex color gradients. It uses lossy compression, discarding image data to reduce file size. At quality settings of 80-85, JPG produces excellent results with file sizes 60-75% smaller than uncompressed images.

JPG struggles with sharp edges and text, where compression artifacts become visible. It also lacks transparency support. Use JPG for photographs and complex imagery where slight quality loss is acceptable. Compress JPG images to reduce file sizes while maintaining quality.

PNG

PNG uses lossless compression, preserving every pixel exactly. This makes it ideal for images requiring perfect quality: logos, screenshots, graphics with text, and images needing transparency.

The tradeoff is larger file sizes. A PNG photograph can be 3-5x larger than an equivalent JPG. Use PNG only when you need transparency or pixel-perfect reproduction. Compress PNG images to reduce file sizes without quality loss.

WebP

WebP is a modern format developed by Google that supports both lossy and lossless compression, plus transparency and animation. A lossy WebP is typically 25-35% smaller than a comparable JPG with equivalent visual quality.

With browser support now exceeding 96%, WebP is a practical default for most web images. You can convert JPG to WebP or PNG to WebP in bulk to modernize existing image libraries.

AVIF

AVIF offers the best compression efficiency currently available, often producing files 50% smaller than JPG with no perceptible quality loss. It supports both lossy and lossless compression, transparency, and high dynamic range.

The main limitation is browser support—currently around 95% globally. AVIF also has slower encoding times, making it less practical for real-time processing. Use AVIF as a progressive enhancement, with WebP or JPG fallbacks. You can convert JPG to AVIF or PNG to AVIF in bulk for maximum compression.

Working with iPhone Photos

iPhone cameras shoot in HEIC format by default, which isn't universally supported by web browsers. Before uploading iPhone photos to your website, convert HEIC to JPG or HEIC to WebP for universal browser compatibility.

Format Comparison

FormatCompressionTransparencyBrowser SupportBest For
JPGLossyNo100%Photos, complex imagery
PNGLosslessYes100%Logos, screenshots, transparency
WebPBothYes96%+General purpose, modern default
AVIFBothYes95%Maximum compression

Progressive Enhancement with Picture

Use the HTML <picture> element to serve the most efficient format each browser supports:

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="Description" width="800" height="600">
</picture>

To create format variants for the <picture> element, convert your source images to multiple formats using Convert.FAST. Process entire folders at once to generate AVIF, WebP, and JPG versions of every image.

For a deeper understanding of compression trade-offs, see our guide on image formats. For detailed compression quality settings and metadata handling, see our guide on how to optimize images for web.

Serving Responsive Images for Every Device

Modern websites must serve users on devices ranging from small mobile phones to 4K desktop monitors. Responsive images ensure each device receives an appropriately sized file—not a one-size-fits-all approach that wastes bandwidth on mobile or looks blurry on desktop.

Understanding srcset

The srcset attribute provides the browser with multiple image sources at different widths. The browser then selects the most appropriate one based on the viewport size and device pixel ratio.

srcset with Width Descriptors

List each image variant with its intrinsic width using the w descriptor:

<img
  srcset="hero-400.jpg 400w,
          hero-800.jpg 800w,
          hero-1200.jpg 1200w,
          hero-1600.jpg 1600w,
          hero-2000.jpg 2000w"
  sizes="100vw"
  src="hero-1200.jpg"
  alt="Hero image"
  width="1200"
  height="600">

The sizes Attribute

The sizes attribute tells the browser how wide the image will actually display at different viewport sizes. This helps it select the optimal source from srcset before downloading.

sizes with Media Conditions

Specify display widths at different breakpoints:

<img
  srcset="product-300.jpg 300w,
          product-600.jpg 600w,
          product-900.jpg 900w"
  sizes="(max-width: 640px) 100vw,
         (max-width: 1024px) 50vw,
         300px"
  src="product-600.jpg"
  alt="Product image">

This tells the browser: on mobile (under 640px), the image fills the viewport (100vw). On tablets (640-1024px), it takes half the viewport (50vw). On desktop, it displays at 300px wide.

Art Direction with Picture

Sometimes you need different crops or compositions for different screen sizes—not just different resolutions of the same image. The <picture> element enables art direction by letting you specify completely different images for different media conditions.

Art Direction Example

Serve a wide landscape crop on desktop and a tighter portrait crop on mobile:

<picture>
  <source media="(min-width: 1024px)" srcset="hero-wide.jpg">
  <source media="(min-width: 640px)" srcset="hero-medium.jpg">
  <img src="hero-mobile.jpg" alt="Hero image">
</picture>

Retina and High-DPI Displays

Modern displays often have pixel ratios of 2x or 3x, meaning they pack more physical pixels into each CSS pixel. To appear sharp on these displays, images need to be served at 2x their displayed dimensions.

  • 1x displays — Standard resolution. A 400px container needs a 400px image.
  • 2x displays (Retina) — Most modern phones and laptops. A 400px container needs an 800px image for sharpness.
  • 3x displays — High-end phones (iPhone Pro). A 400px container ideally needs a 1200px image.

Practical Retina Strategy

Serving 2x images is usually sufficient. The visual difference between 2x and 3x is minimal, and 3x images significantly increase file sizes. Generate images at 1x, 1.5x, and 2x for a practical balance of quality and performance.

Always Set Width and Height

Always include width and height attributes on your images. This allows browsers to reserve the correct space before the image loads, preventing Cumulative Layout Shift (CLS). Use CSS to make images responsive while maintaining aspect ratio:

img {
  max-width: 100%;
  height: auto;
}

Streamlining Your Image Sizing Workflow

Manual image optimization is tedious and error-prone when dealing with dozens or hundreds of images. Automation ensures consistent quality and sizing across your entire image library.

Desktop Tools for Manual Processing

For occasional image work, desktop applications provide quick, visual editing:

  • Adobe Photoshop — Industry standard with "Save for Web" export presets. Offers precise control over quality and dimensions.
  • GIMP — Free, open-source alternative with similar capabilities for resizing and exporting.
  • Preview (macOS) — Built-in tool that handles basic resizing and format conversion for quick tasks.
  • Squoosh — Google's free web app for comparing compression settings visually before export.

Build-Time Automation

Modern web frameworks include built-in image optimization that automatically generates multiple sizes and formats during the build process:

  • Next.js Image — The <Image> component automatically optimizes, resizes, and serves images in modern formats with lazy loading.
  • Nuxt Image — Similar functionality for Vue applications, with automatic srcset generation and format conversion.
  • Astro — Built-in astro:assets handles optimization with support for WebP and AVIF output.
  • Gatsby — gatsby-plugin-image provides automatic responsive image generation during build.

Command-Line Processing

For batch processing outside a framework, command-line tools offer powerful automation:

ImageMagick Batch Resize

Generate multiple sizes from source images:

# Resize all JPGs to 1200px wide, maintaining aspect ratio
mogrify -resize 1200x -quality 85 *.jpg

# Generate multiple sizes for responsive images
for size in 400 800 1200 1600; do
  convert input.jpg -resize ${size}x -quality 85 output-${size}.jpg
done

Bulk Processing for Existing Libraries

For migrating existing image libraries or one-time optimization projects, bulk compression tools process hundreds or thousands of images at once. This is essential for sites with legacy content that was never properly optimized.

Compress.FAST processes images on secure EU servers with automatic deletion. Upload up to 1,000 files per batch on paid plans.

Frequently Asked Questions

Here are direct answers to common questions about image sizing for websites.

What is the best pixel size for a website image?

There is no single "best" size—it depends on where the image appears and how it's displayed. The right size matches the container width at the highest resolution you need to support.

For hero images and full-width banners, 1920px wide is the practical maximum for most sites, with 2560px for sites targeting 4K displays. Content images within articles typically work well at 800-1200px. Thumbnails in grids or cards should be 300-500px.

The key is to avoid serving images significantly larger than their display size. A 4000px image displayed at 400px wastes 99% of its data.

Should I worry about 72 DPI vs. 300 DPI for the web?

No. DPI (dots per inch) is a print metric that web browsers completely ignore. A 1000x1000 pixel image displays identically whether it's saved at 72 DPI or 300 DPI—browsers only use pixel dimensions.

Changing DPI settings in Photoshop or other editors has zero effect on web display. Focus your optimization efforts on pixel dimensions and file size instead.

How do I make images look sharp on retina displays?

Retina and high-DPI displays have pixel ratios of 2x or higher, meaning they need images with more pixels to appear sharp. The solution is to provide images at 2x their displayed CSS dimensions.

For an image displayed at 400px wide, provide an 800px wide image. Use the srcset attribute to let browsers automatically select the appropriate resolution based on the device's pixel ratio.

Going beyond 2x to 3x provides diminishing returns—the visual improvement is minimal while file sizes increase significantly. Serving 2x images is the practical sweet spot for most use cases.

What is the maximum file size for a website image?

While there's no hard technical limit, practical guidelines exist based on performance impact. Hero images and large banners should stay under 200 KB. Content images within articles should target under 100 KB. Thumbnails should be under 30 KB.

The total image weight for a single page should ideally stay under 1.5 MB. For image-heavy pages like galleries, use lazy loading to defer loading of off-screen images so they don't impact initial page load.

Use tools like PageSpeed Insights to identify specific images causing performance issues on your site.

Compress.FAST processes images on secure EU servers with automatic deletion. Upload up to 1,000 files per batch on paid plans.

Stewart Celani

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. Compress.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