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