Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get a users physical screen size without the use of a physical object or the diagonal measurement?

Question says it all really. I want to be able to display something at actual size, so, for example, if something is displayed in the browser as 20cm, I want to be able to measure it and it to actually be 20cm.

So far I have come across solutions which take into account the diagonal resolution of the screen (such as 21.5 inches) and the screen resolution to calculate how big a pixel is.

Another approach is to ask the user to put up a standard sized card such as a bank card to the screen and measure the edges to calculate the size.

Is there a way to do this without a physical object on the screen or without the user needing to know their diagonal screen size?

Please also let me know if you know of any different solutions other than the ones I have mentioned.

like image 573
betamax Avatar asked Jul 26 '11 13:07

betamax


People also ask

How to find the width and height of your screen?

The size of a desktop computer monitor is determined by physically measuring the screen. Using a measuring tape, start at the top-left corner and pull it diagonally to the bottom-right corner. Be sure to only measure the screen; do not include the bezel (the plastic edge) around the screen.

How do I find my screen size in pixels?

Get Viewing Window Size You can use window. innerHeight and window. innerWidth to get the size of the window for the web page as the user sees it.


1 Answers

You can't do this with absolute certainty, no. For example, if the display device is not a screen, but a video projector, the effective size will depend on the distance of the projector to the wall, which can change without the operation system getting any feedback.


Most operation systems have some dpi setting (dots per inch), which might either be configured by the user or system administrator, hard-coded (if the video device is build in and can't be changed, like a laptop screen), or maybe automatically discovered (if the video protocol supports this).

Either this setting or a similar browser setting will be used by the browser to calculate absolute sizes used in CSS, like cm, mm, in, pt, and so on.

So you could simply rely on the browser to show it right, or tell your user to set the setting right. (Of course, on a video projector with projection size 3×4 m you don't really want to show a 20 cm object.)

like image 113
Paŭlo Ebermann Avatar answered Sep 20 '22 00:09

Paŭlo Ebermann