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

dep

parent 46ac0580
...@@ -128,46 +128,46 @@ class IndexController extends Controller ...@@ -128,46 +128,46 @@ class IndexController extends Controller
} }
//圆图 //圆图
public function yuan_img($user_pic,$num){ // public function yuan_img($user_pic,$num){
$ext = pathinfo($user_pic); // $ext = pathinfo($user_pic);
$src_img = null; // $src_img = null;
switch ($ext['extension']) { // switch ($ext['extension']) {
case 'jpg': // case 'jpg':
$src_img = imagecreatefromjpeg($user_pic); // $src_img = imagecreatefromjpeg($user_pic);
break; // break;
case 'png': // case 'png':
$src_img = imagecreatefrompng($user_pic); // $src_img = imagecreatefrompng($user_pic);
break; // break;
} // }
$wh = getimagesize($user_pic); // $wh = getimagesize($user_pic);
$w = $wh[0]; // $w = $wh[0];
$h = $wh[1]; // $h = $wh[1];
$w = min($w, $h); // $w = min($w, $h);
$h = $w; // $h = $w;
$img = imagecreatetruecolor($w, $h); // $img = imagecreatetruecolor($w, $h);
imagesavealpha($img, true); // imagesavealpha($img, true);
//拾取一个完全透明的颜色,最后一个参数127为全透明 // //拾取一个完全透明的颜色,最后一个参数127为全透明
$bg = imagecolorallocatealpha($img, 255, 255, 255, 127); // $bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagefill($img, 0, 0, $bg); // imagefill($img, 0, 0, $bg);
$r = $w / 2; //圆半径 // $r = $w / 2; //圆半径
$y_x = $r; //圆心X坐标 // $y_x = $r; //圆心X坐标
$y_y = $r; //圆心Y坐标 // $y_y = $r; //圆心Y坐标
for ($x = 0; $x < $w; $x++) { // for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) { // for ($y = 0; $y < $h; $y++) {
$rgbColor = imagecolorat($src_img, $x, $y); // $rgbColor = imagecolorat($src_img, $x, $y);
if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) { // if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
imagesetpixel($img, $x, $y, $rgbColor); // imagesetpixel($img, $x, $y, $rgbColor);
} // }
} // }
} // }
//
$path = "H5/pimg/"; // $path = "H5/pimg/";
if (!is_dir($path)){ // if (!is_dir($path)){
mkdir($path,0777,true); // mkdir($path,0777,true);
} // }
//
imagepng($img,$path.$num.'.png'); // imagepng($img,$path.$num.'.png');
} // }
//缩略图 //缩略图
public function thumb($user_pic,$num){ 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