I am trying to duplicate and work with images from Facebook profiles. I can get the images just fine. The majority of them are 'jpgs' however, some of them are 'pngs' and even a few are 'gifs'. There may be others that I don't know about.
My issue. I need to find out what type of image they are before I work with them.
The below code works to get the image and with json I get the url... but the last line of code will not work unless I have the right image type.
$json = file_get_contents("http://graph.facebook.com/$user[id]/picture?width=512&height=512&redirect=false");
$decoded = json_decode($json,true);
$url = $decoded['data']['url'];
/// This line will only work if the image is a jpeg or it throws an error.
$source= imagecreatefromjpeg("$url");
Thank you for your help.