Home > Backend Development > PHP Tutorial > Create rounded images with PHP

Create rounded images with PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-28 08:26:48
Original
1091 people have browsed it
<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>;
}
Copy after login

The above introduces how to create rounded images with PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
img
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
img tag
From 1970-01-01 08:00:00
0
0
0
js find child node img and change src
From 1970-01-01 08:00:00
0
0
0
css - img tag has border
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template