Home / Web Files / Screen Image Size Calculator
Screen Image Size Calculator
Multiply the displayed size by the screen's pixel density. An image shown 640 pixels wide needs a 1280 pixel file for a 2x screen.
How the Math Works
The displayed width and height in CSS pixels are multiplied by 1, 2 and 3 and rounded to whole pixels. The tag below the results uses those widths in the file names so you can match them at export.
How to Use the Tag
Export the three files, upload them and paste the tag into the page. Add a short description of the image inside the alt attribute. Leave it empty only for decoration.
Where the Numbers Come From
- HTML Living Standard, Pixel Density DescriptorWHATWG. Defines the 1x, 2x and 3x labels used in the srcset attribute.
- CSS Values and Units Module Level 3, Absolute LengthsWorld Wide Web Consortium. Fixes one inch at 96 CSS pixels, 72 points and 6 picas.
Questions People Ask
Do I need a 3x image?
A 3x file serves phones with the densest screens. If file weight matters more, list only 1x and 2x and those phones will use the 2x file.
What goes in the width and height attributes?
Use the 1x size in CSS pixels. The browser reserves that space before the file arrives.
The Short Version
- A 2x screen packs two device pixels into each CSS pixel in each direction.
- The srcset attribute lists one file per density and the browser picks one.
- Keep the width and height attributes at the 1x size so the page holds its shape while loading.