/*
* _thumb 获得文件缩略图
* @access public 表示函数对外公开
* @param $_filename 图片路径
* @param $_percent 缩略比例
* return 一张图片
* */
function _thumb($_filename,$_percent){
//生成png表头文件
header("Content-type:image/png");
$_n = explode(".",$_filename);
//取得图片的宽和高
list($_width,$_height)=getimagesize($_filename);
//生成新的宽和高
$_new_width = $_width*$_percent;
$_new_height = $_height*$_percent;
//创建一个以0.4比例的新画布
$_new_image = imagecreatetruecolor($_new_width, $_new_height);
//用已经有的照片创建画布
switch($_n[1]){
case 'png':$_image = imagecreatefromjpeg($_filename);
break;
case 'jpg':$_image = imagecreatefromjpeg($_filename);
break;
case 'gif':$_image = imagecreatefromgif($_filename);
break;
}
imagecopyresampled($_new_image, $_image, 0, 0, 0, 0, $_new_width, $_new_height, $_width, $_height);
imagepng($_new_image);
imagedestroy($_new_image);
imagedestroy($_image);
}