function roundImage($image,$out_path=''){
$logo = imagecreatefromstring(file_get_contents($image));//源图像连接资源
$height = $width = min(imagesx($logo),$imagesy($logo));
//创建一个和原图一样大小的真彩色画布
//$canvas = imagecreatetruecolor(imagesx($logo),$imagesy($logo));//长方图会变成椭圆
$canvas = imagecreatetruecolor($width,$height);//
$color = imagecolorallocatealpha($canvas,255,255,255,127);
imagesavealpha($canvas,true);
imagefill($canvas,0,0,$color);
$r = $width / 2;//半径
for($x = 0; $x < $width;$x++){
for($y=0;$y<$height;$y++){
$rgb_color = imagecolorat($logo,$x,$y);
if(((($x - $r)*($x - $r) + ($y - $r)*($y-$r)<($r*$r)))){
imagesetpixel($canvas,$x,$y,$rgb_color);
}
}
}
imagepng($canvas,$out_path);
}