Page 1 of 1

find out an uploaded image dimensions

Posted: Mon Nov 28, 2005 2:58 am
by paladaxar
Once a user has uploaded a image (or while he is uploading the file) is there any way that I can find out the dimensions of the image?

Posted: Mon Nov 28, 2005 3:33 am
by shailendra
Hi,
You can do this by the following two;

imagesx -- Get image width
imagesy -- Get image height


Gud Luck

Posted: Mon Nov 28, 2005 3:45 am
by paladaxar
...the following two...
The following two what? variables? functions? commands? sorry...but I need a little bit more of an explanation than that. Could you provide an example?

Posted: Mon Nov 28, 2005 4:24 am
by shailendra
another way to do this as,

Code: Select all

<?php
$size = getimagesize ("img/flag.jpg");
echo "<img src=\"img/flag.jpg\" {$size[3]}>";
?>
Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF

thanks

Posted: Mon Nov 28, 2005 4:26 am
by paladaxar
thanx...thats exactly what I was looking for