CODE
// Checks if URL is image
if ( $img[2] == 1 )
{
$pic = imagecreatefromgif( $url ) or die();
}
else if ( $img[2] == 2 )
{
$pic = imagecreatefromjpeg( $url ) or die();
}
else if ( $img[2] ==3 )
{
$pic = imagecreatefrompng( $url ) or die();
}
else
{
exit();
}
Now, we will make sure that the image requested is an actual image. We will be using element two of our function to check that. The three main image types that we will allow are
gif, jpeg, png. If the image cannot be produced and it is a valid image, we will stop the script by using
die(). If the image is one of those, we will use the correct function that matches our image type in order to create the thumbnail. If it is not an image, just we will just stop the process by using the
exit() function.