...
|
...
|
@@ -346,7 +346,57 @@ class Mycenter extends Api |
|
|
*/
|
|
|
public function getUserPoster()
|
|
|
{
|
|
|
$ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
|
|
|
$text = '13255d';
|
|
|
$box = imagettfbbox(20,0,$ttf,$text);
|
|
|
// $url = 'https://thirdwx.qlogo.cn/mmhead/6esUwuDZcnic0MfZcGnic6swLgkSJNyqj4YH5r0SWS79c/132';
|
|
|
// $file = file_get_contents($url);
|
|
|
// file_put_contents('./avatar.png',$file);exit();
|
|
|
// $ext = pathinfo(ROOT_PATH.'public/avatar.jpg');
|
|
|
// $src_img = null;
|
|
|
// switch ($ext['extension']) {
|
|
|
// case 'jpg':
|
|
|
// $src_img = imagecreatefromjpeg(ROOT_PATH.'public/avatar.jpg');
|
|
|
// break;
|
|
|
// case 'png':
|
|
|
// $src_img = imagecreatefrompng(ROOT_PATH.'public/avatar.jpg');
|
|
|
// break;
|
|
|
// }
|
|
|
// $wh = getimagesize(ROOT_PATH.'public/avatar.jpg');
|
|
|
// $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);
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// imagepng($img,'./test.jpg');
|
|
|
// imagedestroy($img);
|
|
|
// var_dump($box[4]-$box[6]);exit();
|
|
|
$path = ROOT_PATH.'public/background.png';
|
|
|
$image = Image::open($path);
|
|
|
$image->water('./test.jpg',[550,100]);
|
|
|
$width = 500-($box[4]-$box[6]);
|
|
|
$image->text($text,$ttf,20,'#ffffff',[$width,150]);
|
|
|
$image->text($text,$ttf,20,'#ffffff',[$width,150],[1,0]);
|
|
|
$image->save('123.png');
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|