Skip to content
Omnikalc

Responsive image size calculator: what size file for a 2x screen?

Enter the size of an image on the page, the screen pixel ratio and the format to get the width and height of the file to serve, the megapixels and a rough file size.

Updated on
Your inputs
px

Value out of range

px

Value out of range

Results

Width of the file to serve

1,200 px

Height of the file to serve
800 px
Megapixels
0.96 MP
Estimated file size
234.4 KB
Extra pixels compared with a 1× image
300%

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.

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.

Frequently asked questions

Why do I need a bigger image for a retina screen?

A high-density screen has several physical pixels in each CSS pixel. On a 2× screen, an image that fills 600 CSS pixels spans 1,200 device pixels, and a 600 pixel file would be stretched and look soft. Serving a file at twice the width keeps it sharp.

How can I serve the right size to each device?

Use the srcset and sizes attributes of the img element, or the picture element, to list several widths of the same image. The browser then picks the file that matches the screen and the layout. Provide widths such as 600, 1,200 and 1,800 px and let the browser choose.

How accurate is the file size?

It is a rough guide for photos. The real size depends on the content, the quality setting and the encoder: a flat graphic is much smaller than a detailed photo, and noise makes any format larger. Use it to compare options and not as a promise. A real file from your tool of choice gives the exact size.

Which format should I use?

WebP and AVIF are smaller than JPEG at similar quality and are supported by current browsers. AVIF gives the smallest files but encodes more slowly. Use PNG or SVG for logos, icons and graphics with sharp edges or transparency, and JPEG, WebP or AVIF for photos.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.