0
嗨,目前我建立了從圖像創建縮略圖的功能,但是我希望它是一個圓形的縮略圖而不是矩形,我怎樣才能做到這一點,而不使用任何外部庫只是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