chmod($uploadfile, 0777);//设定上传的文件的属性
//缩略图
list($width, $height) = getimagesize($uploadfile);
if($width>$height){
$newwidth = 113;
$newheight =$height/$width*113;
$new_x=0;
$new_y=(113-$newheight)/2;
}else{
$newwidth = $width/$height*113;
$newheight = 113;
$new_x=(113-$newwidth)/2;
$new_y=0;
}
// Load
$thumb = imagecreatetruecolor(113, 113);
//bgcolor
$white = ImageColorAllocate($thumb, 255,255,255);
imagefill($thumb,0,0,$white);
$source = imagecreatefromjpeg($uploadfile);
// Resize
imagecopyresized($thumb, $source, $new_x, $new_y, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb,$uploadfile_s,90);
php之缩略图
最新推荐文章于 2025-08-20 11:37:09 发布