How to Resize Images for the Web: Sizes, Retina, srcset and Quality
The most common cause of a slow website is not code. It’s images that are far bigger than they need to be. A photo straight from a phone is typically 4000 × 3000 pixels and 3–6 MB. On a web page it might be displayed 800 pixels wide. That means the browser downloads over twenty times more pixels than it can show, then throws them away. Resizing is the first and most effective image optimization, before compression or format choice.
Pixels are what count
File size grows roughly with the number of pixels. Halving the width and height of an image removes three quarters of its pixels:
| Dimensions | Pixels | Relative pixel count |
|---|---|---|
| 4000 × 3000 | 12,000,000 | 100% |
| 2000 × 1500 | 3,000,000 | 25% |
| 1600 × 1200 | 1,920,000 | 16% |
| 1000 × 750 | 750,000 | 6% |
Compression settings and formats matter, but nothing reduces weight as dramatically as not sending pixels nobody sees.
Find the display size
To choose a size, find the largest width at which the image is actually displayed. Right-click the image in your browser, inspect it, and look at its rendered width in CSS pixels. A blog layout with a 760px content column displays images at up to 760px; a full-width hero on a large desktop might be 1920px or more.
Account for high-density screens
Most phones and many laptops have a device pixel ratio (DPR) of 2 or 3, meaning each CSS pixel is drawn with 2×2 or 3×3 physical pixels. An image displayed at 760 CSS pixels needs about 1520 pixels of width to look perfectly sharp on a 2x screen.
| Display width (CSS px) | 1x asset | 2x asset | 3x asset |
|---|---|---|---|
| 360 (phone, full width) | 360 | 720 | 1080 |
| 760 (article column) | 760 | 1520 | 2280 |
| 1280 (wide hero) | 1280 | 2560 | 3840 |
For photos, 2x is usually the sweet spot. The visible gain from 3x photographs is small, and the file size cost is large. For logos and icons, use SVG instead, which is sharp at any density. You can check your own screen’s DPR with our screen resolution checker.
Serve the right size to each device: srcset
A single 2x image is too heavy for small phones and possibly too small for large desktops. HTML’s responsive image attributes let the browser choose:
<img
src="photo-1280.webp"
srcset="photo-640.webp 640w, photo-1280.webp 1280w, photo-1920.webp 1920w"
sizes="(max-width: 800px) 100vw, 760px"
width="1280" height="853"
alt="Team at work in the studio">srcsetlists the available files and their widths.sizestells the browser how wide the image will be displayed at different screen sizes.- The browser combines that with the device’s DPR and picks the smallest file that looks sharp.
Three widths (for example 640, 1280 and 1920) cover most layouts well. Always include width and height attributes (or CSS aspect-ratio) so the browser reserves space and the page doesn’t jump as images load. We explain why in our article on layout shift and placeholder images.
Quality when resizing
Downscaling (making images smaller) keeps them sharp, as long as the software uses good resampling. Browsers’ canvas drawing with imageSmoothingQuality = "high" and design tools like Photoshop use resampling filters that average neighbouring pixels to avoid jagged edges and shimmering patterns.
Upscaling (making images larger) can’t add detail that isn’t there. A 600px image stretched to 1200px looks soft. AI upscalers can invent plausible detail, but for professional work, start with a large enough original.
A few practical rules:
- Resize from the original, not from an already-reduced copy.
- Crop before resizing, so you keep as many useful pixels as possible.
- Keep an untouched original; resizing down is destructive.
How much resizing alone saves
Here are the same three 12-megapixel photos (4032 × 3024) resized to common widths with Chrome’s encoder, keeping the quality fixed at WebP 75 so only the dimensions change:
| Width | Photo 1 | Photo 2 | Photo 3 |
|---|---|---|---|
| 4032 (original size) | 1.20 MB | 1.54 MB | 1.99 MB |
| 2400 | 552 KB | 565 KB | 931 KB |
| 1600 | 239 KB | 173 KB | 384 KB |
| 1200 | 160 KB | 116 KB | 251 KB |
| 800 | 67 KB | 52 KB | 100 KB |
Halving the width roughly quarters the file, because the pixel count falls with the square of the width. Photo 3, a pine forest full of needles and bark, stays the heaviest at every size, while photo 2, a dog against a soft blurred background, is the lightest from 1600px down. Fine detail costs bytes at any resolution; out-of-focus areas are nearly free. For a blog column around 800 CSS pixels wide, a 1600px file covers 2× screens, and in this test that meant 170–390 KB instead of 1.6–2.4 MB.
Resizing versus compressing versus converting
| Step | What it does | Typical saving on a phone photo |
|---|---|---|
| Resize 4000px → 1600px | Removes pixels | 70–85% |
| Compress (quality 75–80) | Removes detail you can’t see | Another 30–60% |
| Convert JPEG → WebP | More efficient encoding | Another 25–35% |
Combined, a 4 MB photo often ends up at 150–250 KB with no visible difference at its display size. Resize first, then compress, and choose the right format.
Common target sizes
| Use | Suggested width |
|---|---|
| Full-width hero (desktop) | 1920–2560px |
| Blog or article image | 1200–1600px |
| Product image with zoom | 2000px+ |
| Thumbnail or card | 400–800px |
| Email newsletter image | 600–1200px (displayed at 600) |
| Open Graph link preview | 1200 × 630px |
For social platforms, each network has its own sizes; see our social media image sizes guide.
How resizing helps SEO
Google’s Core Web Vitals include Largest Contentful Paint (LCP), which is often an image. Smaller files load faster, improving LCP and the overall experience. Lighthouse and PageSpeed Insights flag “Properly size images” when you serve images much larger than their display size.