有没有写过thinkphp框架,有多图上传,并且生成缩略图功能,求一份啊,
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏10(财富值+成长值)
展开全部
给你段生成缩略图的代码:
// ###############################################################
#(旧路径,新路径,缩放比例)
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);
}
}
// ###############################################################
#(旧路径,新路径,缩放比例)
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);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有很多实例啊,你在百度直接就能搜到
追问
找了好多,都是不完整的,求一份,你有好点的吗??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我的百度空间有,自己查阅
追问
你的空间进不去,百度也搜不到啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询