函数
function openImages( $url = null) { if($url == null) return false; $picinfo = getimagesize($url); switch($picinfo['mime']){ case 'image/jpg': return imagecreatefromjpeg($url); case 'image/jpeg': return imagecreatefromjpeg($url); case 'image/pjpeg': return imagecreatefromjpeg($url); case 'image/png': return imagecreatefrompng($url); case 'image/x-png': return imagecreatefrompng($url); case 'image/gif': return imagecreatefromgif($url); default: return false; } }
使用
打开一个jpeg图片,并返回资源对象
dump(openImages('./2.jpeg'));
输出
resource(17) of type (gd)