最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
超简单php 大图生成缩略图实现代码
时间:2022-06-24 21:07:22 编辑:袖梨 来源:一聚教程网
超简单php教程 大图生成缩略图实现代码
/**
* 生成缩略图
*
* @param string $imagepath 图片路径
* @param string $thumb 生成缩略图名称
* @param integer $width 生成缩略图最大宽度
* @param integer $height 生成缩略图最大高度
**/
function resizeimage($imagepath, $thumb, $, $)
{
list($imagewidth, $imageheight) = getimagesize($imagepath);
$imagepath = imagecreatefromjpeg($imagepath);
if ($width && ($imagewidth < $imageheight))
{
$width = ($height / $imageheight) * $imagewidth;
}
else
{
$height = ($width / $imagewidth) * $imageheight;
}
$image = imagecreatetruecolor($width, $height);
imagecopyresampled($image, $imagepath, 0, 0, 0, 0, $width, $height, $imagewidth, $imageheight);
imagepng($image, $thumb);
imagedestroy($image);
}
resizeimage('test.jpg', 'test_thumb.jpg');
?>
相关文章
- 冬季去杭州西湖旅游,更有可能欣赏到哪种美景 蚂蚁庄园今日答案1.12 08-05
- 蚂蚁庄园小课堂今日最新答案2026年1月12日 08-05
- 蚂蚁庄园小课堂2026年1月12日最新题目答案 08-05
- 在寒冷的冬天,湖里的鱼会冬眠吗 蚂蚁庄园今日答案1月12日 08-05
- 《我的世界手游》狐狸食物怎么获得-狐狸喜欢吃什么食物 08-05
- 幽灵捕捞是什么 神奇海洋1月12日答案最新 08-05