首页 >后端开发 >php教程 >PHP制作圆角图片

PHP制作圆角图片

WBOY
WBOY原创
2016-07-28 08:26:481035浏览
<span>public function </span><span>get_lt_rounder_corner</span>(<span><em>$radius</em></span>)
{
    <span>$img </span><span>= </span><span><em>imagecreatetruecolor</em></span>(<span><em>$radius </em></span><span>* </span><span>2</span>, <span><em>$radius </em></span><span>* </span><span>2</span>);  <span>// </span><span>创建一个正方形的图像
</span><span>$bgcolor </span><span>= </span><span><em>imagecolorallocate</em></span>(<span>$img</span>, <span>255</span>, <span>255</span>, <span>255</span>);   <span>// </span><span>图像的背景
</span><span>$fgcolor </span><span>= </span><span><em>imagecolorallocate</em></span>(<span>$img</span>, <span>0</span>, <span>0</span>, <span>0</span>);
    <span><em>imagefill</em></span>(<span>$img</span>, <span>0</span>, <span>0</span>, <span>$bgcolor</span>);

    <span><em>imagefilledarc</em></span>(<span>$img</span>, <span><em>$radius</em></span>, <span><em>$radius</em></span>, <span><em>$radius </em></span><span>* </span><span>2</span>, <span><em>$radius </em></span><span>* </span><span>2</span>, <span>180</span>, <span>180</span>, <span>$fgcolor</span>, IMG_ARC_PIE);
    <span>// </span><span>将弧角图片的颜色设置为透明
</span><span><em>imagecolortransparent</em></span>(<span>$img</span>, <span>$fgcolor</span>);
    <span>// </span><span>变换角度
</span><span>// $img = imagerotate($img, 90, 0);
</span><span>    // $img = imagerotate($img, 180, 0);
</span><span>    // $img = imagerotate($img, 270, 0);
</span><span>    // header('Content-Type: image/png');
</span><span>    // imagepng($img);
</span><span>return </span><span>$img</span>;
}

以上就介绍了 PHP制作圆角图片,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn