最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
超简单php 大图生成缩略图实现代码
时间:2011-04-09 编辑:简简单单 来源:一聚教程网
超简单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');
?>
-
上一个: 采集QQ校友学校数据代码
相关文章
- php简单实用生成缩略图代码 06-27
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24