Max R. P. Grossmann

Max R. P. Grossmann

Screen size and DPI

Posted: 2020-07-14 · Last updated: 2022-03-02

If your screen has 96 DPI, this means that if you go one inch on your screen, you will come across 96 pixels. (Roughly speaking: This only applies to vertical or horizontal, but not diagonal movement. Also, we will always assume that DPI is identical in every direction. Most notably, this is not the case for many printers and scanners.)

Therefore, if you drew a square with side lengths of one inch, you would surround ${(96\,\text{DPI})^2}\cdot{(1\,\text{in})^2} = {\left(96\,\frac{\text{pixels}}{\text{in}}\right)^2}\cdot{(1\,\text{in})^2} = 9216$ squared pixels (i.e. pixels in a two-dimensional space). In a previous note, I described how we can derive width and height of a 16/9 screen if we know the diagonal. Let us now derive a formula for the relationship between screen resolution, diagonal length and DPI. We continue to assume a 16/9 screen.

Let's write out the formula for $(\text{DPI})^2$ and let me add some context:

$$ \text{DPI}^2 = \left(\frac{\text{pixels}}{\text{in}}\right)^2 = \frac{\overbrace{\text{pixels}^2}^{\text{resolution}}}{\underbrace{\text{in}^2}_{\text{screen area}}}.$$

Given this, we can use the insights of the previous post. However, first of all, know that the "resolution" is defined as the screen area in pixels. It is the product of screen width (in pixels) and screen height (in pixels). For example:

$$ \text{resolution} = w_{\text{px}}\cdot h_{\text{px}} = 1366\cdot 768 = 1049088. $$

The screen area is simply the product of screen width (in inch) and screen height (in inch). From my previous post, we know that

$$ h = \sin(\alpha)\cdot d,$$

$$ w = \cos(\alpha)\cdot d.$$

Therefore, it follows that

$$ \text{screen area} = w\cdot h = \sin(\alpha)\cdot d\cdot \cos(\alpha)\cdot d. $$

There is an identity that says $\sin(\alpha)\cdot \cos(\alpha) = \frac{1}{2}\sin(2\alpha)$, and therefore we have

$$ \text{screen area} = \frac{d^2}{2}\sin(2\alpha). $$

Using this formula, we have

$$ \text{DPI}^2 = \frac{\text{resolution}}{\frac{d^2}{2}\sin(2\alpha)} = 2\frac{\text{resolution}}{d^2 \sin(2\alpha)}. $$

However, remember that we wanted to describe the relationship between screen resolution, diagonal length and DPI. (Also remember that we know $\alpha$. It is approximately 0.5124.) We therefore take the square root and we get

$$ \text{DPI} = \sqrt{\text{DPI}^2} = \sqrt{2\frac{\text{resolution}}{d^2 \sin(2\alpha)}}. $$

The other two formulae (that are probably a bit less useful) are as follows:

$$ \text{resolution} = \frac{1}{2}\,\text{DPI}^2\,d^2 \sin(2\alpha), $$

$$ d = \frac{\sqrt{2\frac{\text{resolution}}{\sin(2\alpha)}}}{\text{DPI}}. $$

We will now apply our knowledge. Consider the iPhone 6s Plus. It has a 5.5 inch display (diagonal measurement) and a screen resolution of $1920\cdot 1080 = 2073600\,\text{pixels}^2$. Apple claims it therefore has 401 DPI. Is this true? Let us apply the first of our final formulae:

$$ \text{DPI} = \sqrt{2\frac{\overbrace{\text{resolution}}^{1920\cdot 1080 = 2073600\,\text{pixels}^2}}{\underbrace{d^2}_{(5.5\,\text{in})^2} \sin(2\underbrace{\alpha}_{\approx 0.5124})}} = 400.5286\,\frac{\text{pixels}}{\text{in}}. $$

After rounding, we do indeed get 401 DPI. Nice, that's a lot!

Let's do another example. I have just scanned a DIN A4 page and the resolution of the resulting image file is 1664 by 2332 pixels. I know that for a sheet of A4, $d = \sqrt{21^2 + 29.7^2} = 36.3743\,\text{cm}$, which is $14.3206\,\text{in}$. What was the DPI setting that I used while scanning?
Note that we now have to adjust $\alpha$, since the ratio is no longer 16/9. We now have: $\alpha = \cot^{-1}(\frac{21}{29.7}) \approx 0.955341 $. See the other post if you do not know how this number is derived.

$$ \text{DPI} = \sqrt{2\frac{\overbrace{\text{resolution}}^{1664\cdot 2332 = 3880448\,\text{pixels}^2}}{\underbrace{d^2}_{(14.3206\,\text{in})^2} \sin(2\underbrace{\alpha}_{\approx 0.955341})}} \approx 200.3487\,\frac{\text{pixels}}{\text{in}}. $$

It is most likely that the setting was 200 DPI.