免费API接口:http://www.wangshuwen.com/portal/article/detail/id/12.html
<http://www.wangshuwen.com/portal/article/detail/id/12.html> 

 
/** * @param string $imgpath 要处理的图片路径 * @return 图片数据 */ private function
changeCircularImg($imgpath) { $ext = pathinfo($imgpath); $src_img = null;
switch ($ext['extension']) { case 'jpg': $src_img =
imagecreatefromjpeg($imgpath); break; case 'png': $src_img =
imagecreatefrompng($imgpath); break; } $wh = getimagesize($imgpath); $w =
$wh[0]; $h = $wh[1]; $w = min($w, $h); $h = $w; $img = imagecreatetruecolor($w,
$h); //这一句一定要有 imagesavealpha($img, true); //拾取一个完全透明的颜色,最后一个参数127为全透明 $bg =
imagecolorallocatealpha($img, 255, 255, 255, 127); imagefill($img, 0, 0, $bg);
$r = $w / 2; //圆半径 $y_x = $r; //圆心X坐标 $y_y = $r; //圆心Y坐标 for ($x = 0; $x < $w;
$x++) { for ($y = 0; $y < $h; $y++) { $rgbColor = imagecolorat($src_img, $x,
$y); if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
imagesetpixel($img, $x, $y, $rgbColor); } } } return $img; }
将返回的数据传入进行保存:imagepng($img,$img_path); 保存后销毁数据:imagedestroy($img);

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信