lammert

msg:4240786 | 1:13 am on Dec 10, 2010 (gmt 0) |
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.
|
kaled

msg:4241560 | 4:39 pm on Dec 12, 2010 (gmt 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.
|
JAB Creations

msg:4241592 | 7:19 pm on Dec 12, 2010 (gmt 0) |
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';} ?> |
|
|
|