Re: checking the aspect ratio of an images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/06/07, blueboy <ross@xxxxxxxxxxxxx> wrote:
I want to force users to insert landscape rather portrait images. I don't
want to be too pedantic about it but they do need to have an approximate 4x3
aspect ratio.

This is my code so far.

$max_height = "500"; // This is in pixels
$max_width = "500"; // This is in pixels

list($width, $height, $type, $w) =
getimagesize($_FILES['userfile']['tmp_name']);

if($width > $max_width || $height > $max_height)
{

}

$ratio = 4/3;
$tolerance = 0.1;

if (abs($ratio - $width/$height) > $tolerance) {
 // not approximately the right aspect ratio
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux