Create an image resource from file, without knowing image type:
<?php
function imagecreatefromfile($imagepath=false) {
if(!$imagepath || !$is_readable($imagepath) return false;
return @imagecreatefromstring(file_get_contents($imagepath));
}
$img_resource=imagecreatefromfile($imagepath);
?>