嗨,目前我建立了从图像创建缩略图的功能,但是我希望它是一个圆形的缩略图而不是矩形,我怎样才能做到这一点,而不使用任何外部库只是PHP内置的方法?谢谢从PHP中的jpeg创建一个圆形缩略图
function createThumb($imagepath, $thumbFile, $thumbWidth)
{
// load image and get image size
$img = imagecreatefromjpeg("$imagepath");
$width = imagesx($img);
$height = imagesy($img);
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor($height * ($thumbWidth/$width));
// create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);
// copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
// save thumbnail into a file in the temp directory below script or somewhere
imagejpeg($tmp_img, $thumbFile);
}
http://stackoverflow.com/questions/8679238/circular-thumbnail-with-php – DevZer0
试试这个:http://php.net/manual/en/function.imagearc.php – senthilbp
也这样: http://stackoverflow.com/questions/2223437/crop-image-into-circle-and-add-border你真的搜索过任何东西吗? – Jorg