View Full Version : How to check for image Dimensions
Phil Vessey
Jan 23rd 2007, 11:20 am
Hi
Im looking for a way to check what the dimensions of an image are using PHP. I need to work out what the width and height are of an image which can be passed to PHP using a URL.
Can anyone help?
Thanks
Phil
sandris
Jan 23rd 2007, 12:03 pm
I don't think that php has function that can get dimensions of remote image. One way to get dimenstions:
Download image file with php and check dimensions with GD(http://www.php.net/gd).
Chemo
Jan 23rd 2007, 12:25 pm
http://www.php.net/manual/en/function.getimagesize.php
smatts9
Jan 23rd 2007, 5:27 pm
<?php
$info = getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif");
echo $info[3];
?>
I'm only displaying the Array[3], but there are your other options too, I tested it with Google's Logo.
Array[0] = Width
Array[1] = Height
Array[2] = Image Type Flag
Array[3] = width="xxx" height="xxx"
Array[bits] = bits
Array[channels] = channels
Array[mime] = mime-type
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.