Commit 96702231 authored by 章建武's avatar 章建武

dep

parent 46ac0580
......@@ -128,46 +128,46 @@ class IndexController extends Controller
}
//圆图
public function yuan_img($user_pic,$num){
$ext = pathinfo($user_pic);
$src_img = null;
switch ($ext['extension']) {
case 'jpg':
$src_img = imagecreatefromjpeg($user_pic);
break;
case 'png':
$src_img = imagecreatefrompng($user_pic);
break;
}
$wh = getimagesize($user_pic);
$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);
}
}
}
$path = "H5/pimg/";
if (!is_dir($path)){
mkdir($path,0777,true);
}
imagepng($img,$path.$num.'.png');
}
// public function yuan_img($user_pic,$num){
// $ext = pathinfo($user_pic);
// $src_img = null;
// switch ($ext['extension']) {
// case 'jpg':
// $src_img = imagecreatefromjpeg($user_pic);
// break;
// case 'png':
// $src_img = imagecreatefrompng($user_pic);
// break;
// }
// $wh = getimagesize($user_pic);
// $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);
// }
// }
// }
//
// $path = "H5/pimg/";
// if (!is_dir($path)){
// mkdir($path,0777,true);
// }
//
// imagepng($img,$path.$num.'.png');
// }
//缩略图
public function thumb($user_pic,$num){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment