check picture size(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
lizlazloz
Forum Commoner
Posts: 64
Joined: Mon Dec 29, 2003 7:29 am

check picture size(dimensions)

Post by lizlazloz »

hi, i'm making a kind of profile area for my site, and i'm allowing the user to have a profile picture which they link to from another site.

is there anyway for me to automatically check the dimensions of the picture before it is chosen, say that it is under 400x400 pixels?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Use getimage(). The result it generates is an array with width and height that you can use later to check against.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

getimagesize()

getimagesize -- Get the size of an image
Description
array getimagesize ( string filename [, array imageinfo])


The getimagesize() function will determine the size of any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM, or WBMP image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag.

You just get the imagesize and then check weather it is acceptable to the size that you have Standardized or not if yes then use it else leave a message that "Change the size of image"
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

http://www.php.net/manual/en/function.getimagesize.php

All the informition about the above function.....
Post Reply