<p>The OS does not, in many or most cases, know the physical screen size! Often the only thing you can glean is the make and model, sometimes not even that. So if you do not want to have a database then the best you can do is ask your user.</p>

<p>There are also some interesting corner cases. What do you do if the monitor is in fact a projector? What do you do in multi monitor setups? What if the image is halfway between 2 monitors? What do you do if the operator is using pixel zoom for accessibility reasons? What do you do if the image is shown on 2 monitors at the same time? What do you do if the monitor is huge, like one used in a conference room and your image turns out to be very small in comparison (like 4 by 4 pixels)? ...</p>

CC BY-SA 3.0
2017-01-05T11:44:40.893Z
Yep, thank you for adding these questions; some of them I already had them on my list. I am a bit puzzled how to use or create a proper DB for this as it seems to require a lot of accurate resources. I was hoping for an alternate/possible solution..
4673_j
CC BY-SA 3.0
2017-01-05T11:47:17.193Z
@4673_j This is why even Adobe does not implement this function. Even though their users would benefit (and they would get the DB in no time by asking users). Basically its not entirely feasible at current date.
joojaa
CC BY-SA 3.0
2017-01-05T11:55:15.507Z
Hm.. I might have a partial solution in my case, as there might be ~10 different monitors/screens. I'm searching now how to extract that information from the system. Thanks for your effort. I think this kind of "feature/info" has to be provided by the OS, not just the resolution; as the OS has direct access to all physical components.
4673_j
CC BY-SA 3.0
2017-01-05T11:58:13.053Z
@4673_j Its good that this info did not exist back in 1995 or oherwise the web would still be designed like a print publication. Its a good thing that the os does not try to react to my monitors DPI or it would defeat many normal operations.
joojaa
CC BY-SA 3.0
2017-01-04T14:12:05.507Z
2017-01-04T16:32:36.503Z
2017-01-04T16:32:36.503Z
joojaa
<p>Back in the days, MSDN defined a couple of values which in most cases are useless (total crap):</p>

<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx</a></p>

<pre><code>int width_mm = GetDeviceCaps(hdx, HORZSIZE);
int height_mm = GetDeviceCaps(hdx, VERTSIZE);
</code></pre>

<p>However, there is a way to retrieve the information through VESA. Any modern monitor should be able to handle that. Only I have no clue how that's done. Under Linux you have a command called <code>xrandr</code> which can be used to find out the info:</p>

<pre><code>% xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
VGA-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 553mm x 311mm
   1920x1080     60.00*+
   1680x1050     59.95  
   1600x1200     60.00  
   1440x900      59.89  
   1280x1024     60.02  
   1280x960      60.00  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
</code></pre>

<ul>
<li>Note that I verified and my monitor dimensions in mm are correct in the output of my <code>xrandr -q</code> command.</li>
</ul>

<p>I would suggest you look at how that <code>xrandr</code> tool does it and you'd get your info right at hand.</p>

<p>From what I've read over the years, the VESA info can be wrong once in a while, but it's quite reliable now a day, I would think.</p>

CC BY-SA 3.0
2018-04-20T10:24:19.043Z
Hm.. sounds interesting, I'll have a look over VESA. I'm fine with linux, yet most of the users for this program are using Windows. I'll start here, see how far I can get. Thanks for your time.
4673_j
CC BY-SA 3.0
2018-04-19T09:15:50.597Z
2018-04-20T15:57:51.577Z
2018-04-20T15:57:51.577Z
Alexis Wilke
<p>I'm a programmer working in Java and I'm not sure if this is the right place to ask this kind of question, here it goes:</p>

<p>In my program, I need to show an image (.jpeg .png etc.) based on the screen size, this image is used to compare to real size (physical) of an actual label which is later printed on a specific machine.</p>

<p>The issue is, for example on my machine I have the laptop screen and a '27 monitor they are both using the same resolution 1920x1080 but as you imagine if you resize any window/program/image it looks smaller on the laptop as the physical screen size is different although it has the same resolution (I imagine is because the physical size of the pixel is smaller than the ones on my monitor)</p>

<p>Now what I would need to do is somehow always show the image on it's corect physical size (as it were printed), on any type of screen.</p>

<p>Regarding to programming I could easily get the screens size and resize the image but, this is because the OS gives the size (it's set up size) back to the program, yet even if I have the correct size the physical screen could display the image smaller for example, as the screen's pixels are smaller.</p>

<p>Any ideas where to start with this?
How can I know the real physical screen size?
This seems to be more a hardware issue than graphics..</p>

<pixel-graphics>
Get screen size and then resize image accordingly
4673_j
# Get screen size and then resize image accordingly

(Asked by: username_0 on 2017-01-03)

I'm a programmer working in Java and I'm not sure if this is the right place to ask this kind of question, here it goes:

In my program, I need to show an image (.jpeg .png etc.) based on the screen size, this image is used to compare to real size (physical) of an actual label which is later printed on a specific machine.

The issue is, for example on my machine I have the laptop screen and a '27 monitor they are both using the same resolution 1920x1080 but as you imagine if you resize any window/program/image it looks smaller on the laptop as the physical screen size is different although it has the same resolution (I imagine is because the physical size of the pixel is smaller than the ones on my monitor)

Now what I would need to do is somehow always show the image on it's corect physical size (as it were printed), on any type of screen.

Regarding to programming I could easily get the screens size and resize the image but, this is because the OS gives the size (it's set up size) back to the program, yet even if I have the correct size the physical screen could display the image smaller for example, as the screen's pixels are smaller.

Any ideas where to start with this?
How can I know the real physical screen size?
This seems to be more a hardware issue than graphics..

**Tags:** pixel-graphics


---

## 2 answers

### Answer by username_1 on 2017-01-04. Score: 4

The OS does not, in many or most cases, know the physical screen size! Often the only thing you can glean is the make and model, sometimes not even that. So if you do not want to have a database then the best you can do is ask your user.

There are also some interesting corner cases. What do you do if the monitor is in fact a projector? What do you do in multi monitor setups? What if the image is halfway between 2 monitors? What do you do if the operator is using pixel zoom for accessibility reasons? What do you do if the image is shown on 2 monitors at the same time? What do you do if the monitor is huge, like one used in a conference room and your image turns out to be very small in comparison (like 4 by 4 pixels)? ...

> **Comments:**
> **username_0**: Yep, thank you for adding these questions; some of them I already had them on my list. I am a bit puzzled how to use or create a proper DB for this as it seems to require a lot of accurate resources. I was hoping for an alternate/possible solution..  
> **username_1**: @username_0 This is why even Adobe does not implement this function. Even though their users would benefit (and they would get the DB in no time by asking users). Basically its not entirely feasible at current date.  
> **username_0**: Hm.. I might have a partial solution in my case, as there might be ~10 different monitors/screens. I'm searching now how to extract that information from the system. Thanks for your effort. I think this kind of "feature/info" has to be provided by the OS, not just the resolution; as the OS has direct access to all physical components.  
> **username_1**: @username_0 Its good that this info did not exist back in 1995 or oherwise the web would still be designed like a print publication. Its a good thing that the os does not try to react to my monitors DPI or it would defeat many normal operations.  

---

### Answer by username_2 on 2018-04-19. Score: 2

Back in the days, MSDN defined a couple of values which in most cases are useless (total crap):

<https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx>

```
int width_mm = GetDeviceCaps(hdx, HORZSIZE);
int height_mm = GetDeviceCaps(hdx, VERTSIZE);

```

However, there is a way to retrieve the information through VESA. Any modern monitor should be able to handle that. Only I have no clue how that's done. Under Linux you have a command called `xrandr` which can be used to find out the info:

```
% xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
VGA-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 553mm x 311mm
   1920x1080     60.00*+
   1680x1050     59.95  
   1600x1200     60.00  
   1440x900      59.89  
   1280x1024     60.02  
   1280x960      60.00  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)

```

* Note that I verified and my monitor dimensions in mm are correct in the output of my `xrandr -q` command.

I would suggest you look at how that `xrandr` tool does it and you'd get your info right at hand.

From what I've read over the years, the VESA info can be wrong once in a while, but it's quite reliable now a day, I would think.

> **Comments:**
> **username_0**: Hm.. sounds interesting, I'll have a look over VESA. I'm fine with linux, yet most of the users for this program are using Windows. I'll start here, see how far I can get. Thanks for your time.  

---

