/**
*
* Loads a file based on its filetype and returns false if it fails.
*/
function imagecreatefromfile($path, $user_functions = false)
{
$info = @getimagesize($path);
if(!$info)
{
return false;
}
$functions = array(
IMAGETYPE_GIF => 'imagecreatefromgif',
IMAGETYPE_JPEG => 'imagecreatefromjpeg',
IMAGETYPE_PNG => 'imagecreatefrompng',
IMAGETYPE_WBMP => 'imagecreatefromwbmp',
IMAGETYPE_XBM => 'imagecreatefromwxbm',
);
if($user_functions)
{
$functions[IMAGETYPE_BMP] = 'imagecreatefrombmp';
}
if(!$functions[$info[2]])
{
return false;
}
if(!function_exists($functions[$info[2]]))
{
return false;
}
return $functions[$info[2]]($path);
}