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!
you are going to have to go by if $ext is png then imagecreatefrompng or whatever that function is called then create a jpg with the image created and then do the same thing with the rest
For users without image editing softwear you could use imagecopyresampled() to automatically resize their avatars for them if they go over the limit.
Using gd you could do a switch of the image type, using imagecreatfrom****() for the right kind of image, you could resize the image then call imagejpeg() to output the jpeg image.
If you want to just deny images over your limit, getimagesize()
php.net wrote:Better quality could be obtained using imagecopyresampled().
Might consider taking a look at imagecreatetruecolor(), rather then imagecreate()
Also for obtaining the correct function to use based on the extension something like this works better IMO, due to possible file extension of 'jpg' or 'jpeg' for a jpeg image, a switch is nice in the way it handles multiple cases: