作者 李忠强
1 个管道 的构建 通过 耗费 7 秒

更新

@@ -346,7 +346,57 @@ class Mycenter extends Api @@ -346,7 +346,57 @@ class Mycenter extends Api
346 */ 346 */
347 public function getUserPoster() 347 public function getUserPoster()
348 { 348 {
  349 + $ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
  350 + $text = '13255d';
  351 + $box = imagettfbbox(20,0,$ttf,$text);
  352 +// $url = 'https://thirdwx.qlogo.cn/mmhead/6esUwuDZcnic0MfZcGnic6swLgkSJNyqj4YH5r0SWS79c/132';
  353 +// $file = file_get_contents($url);
  354 +// file_put_contents('./avatar.png',$file);exit();
  355 +// $ext = pathinfo(ROOT_PATH.'public/avatar.jpg');
  356 +// $src_img = null;
  357 +// switch ($ext['extension']) {
  358 +// case 'jpg':
  359 +// $src_img = imagecreatefromjpeg(ROOT_PATH.'public/avatar.jpg');
  360 +// break;
  361 +// case 'png':
  362 +// $src_img = imagecreatefrompng(ROOT_PATH.'public/avatar.jpg');
  363 +// break;
  364 +// }
  365 +// $wh = getimagesize(ROOT_PATH.'public/avatar.jpg');
  366 +// $w = $wh[0];
  367 +// $h = $wh[1];
  368 +// $w = min($w, $h);
  369 +// $h = $w;
  370 +//
  371 +// $img = imagecreatetruecolor($w, $h);
  372 +// //这一句一定要有
  373 +// imagesavealpha($img, true);
  374 +// //拾取一个完全透明的颜色,最后一个参数127为全透明
  375 +// $bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
  376 +// imagefill($img, 0, 0, $bg);
  377 +// $r = $w / 2; //圆半径
  378 +// $y_x = $r; //圆心X坐标
  379 +// $y_y = $r; //圆心Y坐标
  380 +//
  381 +// for ($x = 0; $x < $w; $x++) {
  382 +// for ($y = 0; $y < $h; $y++) {
  383 +// $rgbColor = imagecolorat($src_img, $x, $y);
  384 +//
  385 +// if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
  386 +// imagesetpixel($img, $x, $y, $rgbColor);
  387 +//
  388 +// }
  389 +// }
  390 +// }
  391 +// imagepng($img,'./test.jpg');
  392 +// imagedestroy($img);
  393 +// var_dump($box[4]-$box[6]);exit();
349 $path = ROOT_PATH.'public/background.png'; 394 $path = ROOT_PATH.'public/background.png';
350 $image = Image::open($path); 395 $image = Image::open($path);
  396 + $image->water('./test.jpg',[550,100]);
  397 + $width = 500-($box[4]-$box[6]);
  398 + $image->text($text,$ttf,20,'#ffffff',[$width,150]);
  399 + $image->text($text,$ttf,20,'#ffffff',[$width,150],[1,0]);
  400 + $image->save('123.png');
351 } 401 }
352 } 402 }
不能预览此文件类型