超簡單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 < $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');
?>
http://www.bkjia.com/PHPjc/632983.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632983.htmlTechArticle超簡單php教程 大圖產生縮圖實現代碼 ?php /** * 產生縮圖 * * @param string $imagepath 圖片路徑 * @param string $thumb 產生縮圖名稱 * @param inte...