有没有写过thinkphp框架,有多图上传,并且生成缩略图功能,求一份啊,
发布网友
发布时间:2022-04-19 04:26
我来回答
共3个回答
热心网友
时间:2022-04-19 05:56
给你段生成缩略图的代码:
// ###############################################################
#(旧路径,新路径,缩放比例)
function CreateImageFile($src_path, $des_path, $new_dims) {
$source = @imagecreatefromjpeg($src_path);
if ($source) {
$imageX = @imagesx($source); #获取原图宽
$imageY = @imagesy($source); #获取原图高
if ($imageX >= $imageY) {
$thumbX = $new_dims;
$thumbY = (int)(($thumbX*$imageY)/$imageX);
} else {
$thumbY = $new_dims;
$thumbX = (int)(($thumbY*$imageX)/$imageY);
}
#$thumbX = (int)($imageX/$new_dims);
#$thumbY = (int)($imageY/$new_dims);
#$dest_thum = @imagecreatetruecolor($new_dims, $new_dims);
$dest_thum = @imagecreatetruecolor($thumbX, $thumbY);
$bg = @imagecolorallocate($dest_thum, 255, 255, 255);
@imagefill($dest_thum, 0, 0, $bg);
#@imagecopyresampled ($dest_thum, $source, ($new_dims - $thumbX)/2, ($new_dims - $thumbY)/2, 0, 0, $thumbX, $thumbY, $imageX, $imageY);
@imagecopyresampled ($dest_thum, $source, 0, 0, 0, 0, $thumbX, $thumbY, $imageX, $imageY);
@imageinterlace($dest_thum);
@imagejpeg($dest_thum,$des_path,100);
@ImageDestroy($dest_thum);
@ImageDestroy($source);
}
}
热心网友
时间:2022-04-19 07:14
有很多实例啊,你在百度直接就能搜到追问找了好多,都是不完整的,求一份,你有好点的吗??
热心网友
时间:2022-04-19 08:48
我的百度空间有,自己查阅追问你的空间进不去,百度也搜不到啊