$thumb = $this->getthumb('.'.$file_info['filepath'], '50', '50');
protected function getthumb($image, $newImageWidth, $newImageHeight)
{
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
$imageType = image_type_to_mime_type($imageType);
switch ($imageType) {
case "image/gif":
$source = imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source = imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source = imagecreatefrompng($image);
break;
default:
$source = imagecreatefromjpeg($image);
break;
}
//图片路径
$arr_tmp = explode('/', $image);
$str_name = "small_".$newImageWidth."_".$arr_tmp[count($arr_tmp) - 1];
unset($arr_tmp[count($arr_tmp) - 1]);
$str_tmp = implode('/', $arr_tmp);
$image_url = $str_tmp.'/'.$str_name;
//最终路径
//$image_url = works/list_FILE.'member/avatar/'.md5($img_name).'_'.$newImageWidth.'.jpg';
$a = copy($image, $image_url); //原图 复制到 新路径中
$newImage = imagecreatetruecolor($newImageWidth, $newImageHeight);
imagecopyresampled($newImage, $source, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $imagewidth, $imageheight);
imagejpeg($newImage, $image_url, '100');
chmod($image_url, 0777);
return $image_url;
}