Re: checking the aspect ratio of an images
| From: | Robin Vickery | Date: | Wed, 06 Jun 2007 11:20:28 +0000 |
| Subject: | Re: checking the aspect ratio of an images | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256164@lists.php.net to get a copy of this message | ||
On 06/06/07, blueboy <ross@aztechost.com> 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 }