Sending a photo that is too small makes it blurry on a phone, and sending one that is too large wastes data and slows the page. The responsive image size calculator takes the size of the image on the page, the screen pixel ratio and the format to give the width and height of the file to serve, the megapixels, a rough file size and the extra pixels compared with a standard screen.
How the calculation works
- Width and height of the file = the size of the image on the page × the screen pixel ratio (DPR). A 2× screen packs 4 device pixels into each CSS pixel, so it needs twice the width and twice the height.
- Megapixels = file width × file height ÷ 1,000,000.
- Estimated file size = pixels × bytes per pixel ÷ 1,024. As a rough guide, a photo takes about 0.25 bytes per pixel as a JPEG at quality 80, about 0.18 as WebP, about 0.12 as AVIF and about 0.9 as a PNG.
- Extra pixels = (ratio² − 1) × 100%. A 2× image has 300% more pixels than a 1× image, which is why it weighs much more.
Example
An image shown at 600 × 400 px on a 2× screen needs a file of 600 × 2 by 400 × 2 = 1,200 × 800 px, which is 0.96 megapixels. As a JPEG at 0.25 bytes per pixel, it weighs about 960,000 × 0.25 ÷ 1,024 ≈ 234 KB. The file has 300% more pixels than the 1× version.
Why it matters
Images are usually the heaviest part of a web page, and they decide how fast it loads on mobile data. Choosing the right pixel size and format keeps pictures sharp and the page light, which helps users, search rankings and the energy used by the site.
Good to know
Do not serve a larger ratio than needed: a 3× image looks nearly the same as a 2× image on most photos and weighs more than twice as much. Compress at a moderate quality and check the result. Always set the width and height attributes or an aspect ratio to avoid layout shifts. The byte estimates are typical values for photos and will differ for your images.
Related tools
The photo storage calculator estimates the disk space of a library, the video file size calculator does the same for video and the website carbon calculator estimates the energy of page weight.