PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

超简单php 大图生成缩略图实现代码_PHP教程

原创
2016-07-13 10:46:01 605浏览

超简单php教程 大图生成缩略图实现代码

 

/**
* 生成缩略图
*
* @param string $imagepath 图片路径
* @param string $thumb 生成缩略图名称
* @param integer $width 生成缩略图最大宽度
* @param integer $height 生成缩略图最大高度
*

*/
function resizeimage($imagepath, $thumb, $width = 200, $height = 200)
{
    list($imagewidth, $imageheight) = getimagesize($imagepath);
    $imagepath = imagecreatefromjpeg($imagepath);
    if ($width && ($imagewidth     {
        $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');
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632983.htmlTechArticle超简单php教程 大图生成缩略图实现代码 ?php /** * 生成缩略图 * * @param string $imagepath 图片路径 * @param string $thumb 生成缩略图名称 * @param inte...
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。