Before you begin
Keep the original untouched. For a 4000 × 3000 px photograph displayed at 800 CSS pixels, prepare 800 px and 1600 px variants. The larger version can serve high-density screens; it need not be downloaded by every visitor.
Text explanation of the diagram
4000 × 3000 → 1600 × 1200 → 800 × 600. Resizing from 4000 × 3000 to 1600 × 1200 reduces the pixel count from 12 million to 1.92 million: an 84% reduction. The file does not necessarily become 84% smaller; content and encoding also matter.
The procedure
- Open Image → Image Size. Link the dimensions and enable Resample when changing the pixel count. Enter 1600 px for width: a 4:3 image becomes 1200 px high.
- Save the editable document separately and export a web copy. Start with JPEG or WebP for a photograph. Compare quality settings at 100%, paying attention to hair, lettering and thin lines.
- Reopen the exported file. Check dimensions, colour, sharpness and actual file size. Use srcset for the variants and provide width/height so the browser can reserve space.
<img src="photo-800.jpg" srcset="photo-800.jpg 800w, photo-1600.jpg 1600w" sizes="(max-width: 800px) 100vw, 800px" width="1600" height="1200" alt="Описание фотографии">A worked example
Resizing from 4000 × 3000 to 1600 × 1200 reduces the pixel count from 12 million to 1.92 million: an 84% reduction. The file does not necessarily become 84% smaller; content and encoding also matter.
Check the result
Test on a narrow screen and a high-density display. Inspect Network to see which file the browser actually selected. A small editor thumbnail cannot demonstrate export quality.
A common mistake
Changing 300 ppi to 72 ppi without resampling does not reduce a web image’s pixel dimensions. PPI connects pixels to printed size; browsers primarily need the correct pixel dimensions.
Sources and next steps
Diagram and examples: Web Article. The diagram explains a principle; it is not an interface capture or a software test result.
Check the chosen file, not only the displayed width
The working example below uses two original teaching images of the same scene, 400 and 800 pixels wide. Its real slot is capped at 400 CSS pixels. You can inspect srcset, sizes and currentSrc against actual files rather than the absent photo-800.jpg in a code fragment.
- Open the example at narrow and wide widths. sizes describes (max-width: 468px) calc(100vw - 68px), 400px. CSS sets the same cap; inspect the real width because its parent can constrain it further.
- Compare slot width and devicePixelRatio. At a 292 CSS-pixel slot, DPR 1 suggests 292 image pixels and DPR 2 suggests 584; at 400 CSS pixels, the corresponding figures are 400 and 800. These are selection inputs, not a guaranteed browser decision.
- Read the displayed currentSrc and the corresponding file size. A resized window may keep a larger file already loaded. For a fresh comparison, reopen at the intended width and record the conditions.
Worked record
| Two real files | scene-400.png and scene-800.png are original explanatory artwork, not archival photographs. |
|---|---|
| Exact HTML | The real src, 400w/800w srcset, sizes and width/height appear below. Both file paths are available. |
| Check record | Viewport __; slot __; DPR __; currentSrc __; selected file bytes __; fresh navigation or resize __. |
| Testing boundary | The displayed DPR is the actual value. Changing viewport width alone does not emulate another display density. |
<img src="/assets/editorial-20261024/scene-400.png" srcset="/assets/editorial-20261024/scene-400.png 400w, /assets/editorial-20261024/scene-800.png 800w" sizes="(max-width: 468px) calc(100vw - 68px), 400px" width="800" height="600" alt="Teaching composition of three rectangles">
Pixel count does not determine file size linearly. The dimensions and byte counts apply to these PNGs; assess photographic quality and encoding separately.
Primary sources: MDN: img, srcset and sizes
An early image request does not remove a late insertion
After choosing dimensions, check when the browser discovers the image. fetchpriority="high" hints at the priority of an already known resource; it does not run deferred JavaScript sooner. A preload can reveal a URL earlier. First identify the actual LCP element: it may be text.
- Download the complete example and extract it into a separate working folder. With Python 3 and no extra packages, run
python3 -m http.server 9460. Openhttp://localhost:9460/a.html, thenb.htmlandc.html. Use HTTP, not file://, for comparable requests. - A includes an ordinary
imgin the initial HTML. B inserts the same element after 300 ms with high fetch priority. C keeps that insertion delay but declares the same PNG early withlink rel="preload" as="image". All three use one asset, dimensions and styling. - Do not click or scroll until the result appears. Record the request’s
startTimeand LCP; confirm thatelementishero. Repeat three times at each width. An unavailable API is reported explicitly; a missing observation is not zero. - Match viewport, zoom, network, cache and exact resource URL. Inspect Network for duplicate requests. Our local server returned
Cache-Control: no-store; these runs used neither network throttling nor a simulated phone.
Observed here: medians of three loads per combination in the built-in browser on 7 November 2026, milliseconds from navigation start. All 18 final LCP observations identified hero. An initial pass captured before observation delivery completed is retained separately and excluded.
| Width | A/B/C | Request, ms | LCP, ms |
|---|---|---|---|
| 360 | a | 12.1 | 72 |
| 360 | b | 329.1 | 376 |
| 360 | c | 10.5 | 360 |
| 1280 | a | 10 | 56 |
| 1280 | b | 325.5 | 364 |
| 1280 | c | 9.2 | 364 |
C requested the file earlier than B, while LCP remained near the delayed insertion. At 1280 px C’s median was no better than B’s: this small series does not demonstrate an LCP improvement. A did not wait for a timer. This is a controlled example with an artificial delay, not field Core Web Vitals or evidence that our site became faster.
Apply the method: first expose the key image in initial HTML and avoid lazy-loading it without a reason. If CSS or JavaScript genuinely hides the resource, evaluate one appropriate preload. Match URL, as, format, responsive candidate and CORS mode to the actual consumer; verify that two requests are not made. Do not assign high priority to every image. The example’s decorative PNG deliberately weighs 1,955,456 bytes; it is not an example of an efficient publishing size.
Record: page/conditions ___; LCP element ___; resource URL ___; discovery method ___; request start/end ___; insertion time ___; LCP ___; repeat count ___; errors/duplicate requests ___; field data after the change ___. An earlier request alone does not prove earlier rendering.
ZIP · HTML/CSS/JS + PNG · CC BY 4.0 · JSON · 18 observations
<link rel="preload" as="image" href="hero.png" fetchpriority="high">
<!-- Same URL is used by the delayed image in c.html. -->web.dev · Optimize Largest Contentful Paint · updated 2025-03-31