Crop image into circle and add border
<p>I'm trying to crop a circle image and adding a border around it. Below is my code to crop a circle image.</p>

<pre><code>&lt;?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 &lt;= $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);

?&gt;
</code></pre>

<p>Any ideas or guide I could add a border around it using PHP GD? </p>
