1
我正在嘗試裁剪一個圓形圖像並在其周圍添加邊框。以下是我的代碼來裁剪一個圓形圖像。將圖像裁剪成圓形並添加邊框
<?php
$img1 = imagecreateFromjpeg("./a.jpg");
$x=imagesx($img1)-$width ;
$y=imagesy($img1)-$height;
$img2 = imagecreatetruecolor($x, $y);
$bg = imagecolorallocate($img2, 255, 255, 255);
imagefill($img2, 0, 0, $bg);
$e = imagecolorallocate($img2, 0, 0, 0);
$r = $x <= $y ? $x : $y;
imagefilledellipse($img2, ($x/2), ($y/2), $r, $r, $e);
imagecolortransparent($img2, $e);
imagecopymerge($img1, $img2, 0, 0, 0, 0, $x, $y, 100);
imagecolortransparent($img1, $bg);
header("Content-type: image/png");
imagepng($img1);
imagedestroy($img2);
imagedestroy($img1);
?>
任何想法或指南我可以使用PHP GD添加一個邊框嗎?
是你建議imagearc添加您的圖像填充在它周圍繞嗎? – Teon 2010-02-09 01:30:15
不,你沒有明白。我將編輯帖子以清除此問題 – naugtur 2010-02-09 11:18:55
謝謝。我想我明白了。 – Teon 2010-02-09 15:25:24