Preview:
function roundrect($im, $x1, $y1, $x2, $y2, $rad, $col) {
    
    imageline($im, ($x1 + $rad), $y1, ($x2 - $rad), $y1, $col);
    imageline($im, ($x1 + $rad), $y2, ($x2 - $rad), $y2, $col);
    imageline($im, $x1, ($y1 + $rad), $x1, ($y2 - $rad), $col);
    imageline($im, $x2, ($y1 + $rad), $x2, ($y2 - $rad), $col);
    imagearc($im, ($x1 + $rad), ($y1 + $rad), (2 * $rad), (2 * $rad), 180, 270, $col);
    imagearc($im, ($x2 - $rad), ($y1 + $rad), (2 * $rad), (2 * $rad), 270, 360, $col);
    imagearc($im, ($x2 - $rad), ($y2 - $rad), (2 * $rad), (2 * $rad), 0, 90, $col);
    imagearc($im, ($x1 + $rad), ($y2 - $rad), (2 * $rad), (2 * $rad), 90, 180, $col);
}


$myImage = imagecreate(200,100);
$myGrey  = imagecolorallocate($myImage,204,204,204);
$myBlack = imagecolorallocate($myImage,0,0,0);
roundrect($myImage, 20, 10, 180, 90, 20, $myBlack);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter