//查询用户信息
$client = $this->where(array('id' => $client_id))->find();
$client_avatar = $client['avatar'];
$mine_code = $client['mine_code'];
$have_code = is_file(SYS_ROOT_PATH . "uploadfiles/qrcode/{$mine_code}.png");
//已经合成的不再重复生成
if (!$have_code) {
//生成原始二维码图
$qrcode = sys_get_qrcode(SYS_ROOT . "index.php/Webservice/V100/register/mine_code/{$mine_code}", "uploadfiles/qrcode/{$mine_code}.png");//网络路径
//原始二维码图的绝对路径
$codeRealPath = SYS_ROOT_PATH . "uploadfiles/qrcode/{$mine_code}.png";
$logo = SYS_ROOT_PATH . "uploadfiles/qrcode-min.png";//准备好的模板图片
if ($qrcode) {
$QR = $codeRealPath;//已经生成的原始二维码图
$QR = imagecreatefromstring(file_get_contents($QR));
$logo = imagecreatefromstring(file_get_contents($logo));
$QR_width = imagesx($QR);//二维码图片宽度
$QR_height = imagesy($QR);//二维码图片高度
//图片合成
imagecopyresampled($logo, $QR, 320, 1948, 0, 0, 445, 445, $QR_width, $QR_height);
//保存到codeRealPath(路径)
imagepng($logo, $codeRealPath);
$path = $codeRealPath;
if ($client['nickname']) {
$img = imagecreatefromstring(file_get_contents($path));
//字体类型
$font = SYS_ROOT_PATH . "uploadfiles/font/wenrui.otf";
//显示的文字
$text = '我是' . $client['nickname'];
//设置字体颜色
$black = imagecolorallocate($img, 255, 255, 255);
imagettftext($img, 26, 0, 470, 1890, $black, $font, $text);
imagepng($img, $path);
}
//合成头像
if ($client_avatar && $client_avatar != '') {
$member_avatar = imagecreatefromstring(file_get_contents($client_avatar));
} else {
$member_avatar = imagecreatefromstring(file_get_contents(SYS_ROOT_PATH . "uploadfiles/default_avatar.png"));
}
$img = imagecreatefromstring(file_get_contents($path));
imagecopyresampled($img, $member_avatar, 500, 2125, 0, 0, 85, 85, imagesx($member_avatar), imagesx($member_avatar));
imagepng($img, $path);
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。