Welcome to WebmasterWorld Guest from 50.17.117.221

Forum Moderators: open

Message Too Old, No Replies

Monitor Aspect Ratio Formula?

     
7:41 pm on Dec 9, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts: 3145
votes: 12


What is the monitor aspect ratio formula as in what are the exact steps and how does it vary from ratio to ratio without going over my head please?

I have one formula at least...

1200 / 1600 x 400 = 300 4:3 (400:300=4:3)

The problem for me is trying to figure out what to multiply by as you can't get the correct numbers by multiplying by 400 each time.

I'm interested in this as I'm curious about the various aspect ratios people use so I'd trying to implement this in to my custom statistics script. I figured it would be more appropriate to post it in the hardware section as it's the actual formula (determining the multiplier to be specific) and not an issue of code for me.

- John
1:13 am on Dec 10, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


Aspect ratios are not always easy numbers. With the older screen resolutions like 640x480, 800x600 or 1280x1024 it was almost always easy to find a small value for the aspect ratio like 4:3 or 5:4. With the new wide screen displays, especially on notebooks you will sometimes find weird values.

What you have to find is the greatest common divisor [en.wikipedia.org] for the horizontal and vertical pixel sizes. I have two monitors here. The easiest example is my desktop screen which is a 19" 1280 x 1024 version:

1280 x 1024 = 2*2*2*2*2*2*5 x 2*2*2*2*2*2*2*2

The greatest common divisor is 2*2*2*2*2*2, which is 256 and gives an aspect ratio of 5:4.

But some screen sizes are more difficult. My other current screen is a wide screen notebook screen with the size 1366 x 768.

1366 x 768 = 2*683 x 2*2*2*2*2*2*2*2*3

683 is not dividable by 2 or 3. The greatest common divisor of these two screensizes is therefore 2, which gives an aspect ratio of 683:384.
4:39 pm on Dec 12, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


There are three major aspect ratios being
 4: 3 (old laptops - typically 1024:768)
16:10 (newer laptops - typically 1280:800)
16: 9 (recent laptops - typically 1366:768)


1280:1024 is unique. For 4:3 1280:960 would have been sensible.

Netbooks use some odd sizes. Rather than log aspect ratios, I would just log the width.

Kaled.
7:19 pm on Dec 12, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts: 3145
votes: 12


I don't know the follow up formula to dynamically generate the numbers directly though this seems to work reasonably well...

- John

<?php
$d = $screen_resolution_y / $screen_resolution_x;
if ($d=='0.75') {$ratio = '4:3';}
else if ($d=='0.8') {$ratio = '5:4';}
else if ($d=='0.625') {$ratio = '16:10';}
else if ($d=='0.5625') {$ratio = '16:9';}
else if (substr($d,0,4)=='0.56') {$ratio = '16:9';}
?>