Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic image format detection in PHP

Tags:

I am looking for a way to take a user uploaded image that is currently put in a temporary location ex: /tmp/jkhjkh78 and create a php image from it, autodetecting the format.

Is there a more clever way to do this than a bunch of try/catching with imagefromjpeg, imagefrompng, etc?

like image 535
MPX Avatar asked Oct 09 '08 22:10

MPX


1 Answers

This is one of the functions of getimagesize. They probably should have called it "getimageinfo", but that's PHP for you.

like image 152
Neall Avatar answered Oct 09 '22 14:10

Neall