← maistrelis.com / tools

Calibration with a physical ruler

Calculate your monitor's DPI (effective DPI)

The browser doesn't know the real size of the screen. Use a real ruler on the glass and match the virtual ruler to it. Once they line up, we know the DPI exactly.

  1. Pick a unit to match the ruler you have (cm or inches).
  2. Hold the ruler against the screen and align its 0 with the virtual ruler's 0.
  3. Move the slider until the marks line up, over as long a span as possible (a longer distance is more accurate).
  4. Do the same for the vertical ruler. Read the result below.

No ruler? You can use a bank card, which has a fixed size of 85.60 × 53.98 mm (the ISO ID-1 standard). On the horizontal ruler, bring its long edge (85.60 mm) onto the orange line. On the vertical one, rest the card on the orange box until they match.

Ruler unit

Horizontal ruler

Horizontal DPI:

Vertical ruler

Card frame (85.60 × 53.98 mm)

Vertical DPI:

Real screen DPI

ppi

Horizontal DPI

Vertical DPI

CSS ppi (what the browser sees)

DPR

Physical size

Diagonal

How the DPI is calculated

The idea: calibration with a ruler

The browser doesn't know the physical size of the screen. With the ruler you give it that information: when the virtual marks fall on the real ones, we know how many CSS pixels cover 1 real centimetre. That figure, call it p (px/cm), is the whole basis of the calculation.

The DPI formula

One inch = 2.54 cm, and each CSS pixel maps to DPR physical pixels of the panel. So the physical pixels per inch (the DPI) are:

$$\mathrm{DPI} = p \times 2.54 \times \mathrm{DPR}$$

We measure it separately for the horizontal and the vertical ruler and show the average:

$$\mathrm{DPI} = \frac{\mathrm{DPI}_H + \mathrm{DPI}_V}{2}$$

In your measurement: p ≈ px/cm · DPR → DPI ≈ ppi

Physical size and diagonal

Knowing how many CSS pixels = 1 inch (that is p × 2.54, the «CSS ppi»), the physical width comes from dividing the screen resolution (in CSS pixels) by it. Likewise the height:

$$w = \frac{W_{\mathrm{px}}}{p_H \times 2.54}, \qquad h = \frac{H_{\mathrm{px}}}{p_V \times 2.54}$$

And the diagonal from the Pythagorean theorem:

$$D = \sqrt{\,w^{2} + h^{2}\,}$$

In your measurement: w ≈ ″ · h ≈ ″ · D ≈

Why the DPR is needed

On high-density (retina) screens a CSS pixel is not one physical pixel; it is DPR physical ones (e.g. 2×2 = 4). The ruler measures in CSS pixels, so to reach the real pixels of the panel we multiply by the DPR. Without it, the DPI would come out half (the «CSS ppi»).