find out an uploaded image dimensions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

find out an uploaded image dimensions

Post 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?
shailendra
Forum Newbie
Posts: 13
Joined: Mon Jun 20, 2005 12:20 am
Location: INDIA
Contact:

Post by shailendra »

Hi,
You can do this by the following two;

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


Gud Luck
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Post 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?
shailendra
Forum Newbie
Posts: 13
Joined: Mon Jun 20, 2005 12:20 am
Location: INDIA
Contact:

Post 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
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Post by paladaxar »

thanx...thats exactly what I was looking for
Post Reply