$url = 'http://xxx';
include APP_PATH . 'lib/phpqrcode/phpqrcode.php';
$filename = time().'.png';
$errorCorrectionLevel = 'L'; //容错级别
$matrixPointSize = 5; //生成图片大小
QRcode::png($url,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
$QR = imagecreatefromstring(file_get_contents($filename));
//输出图片
// imagepng($QR, $filename);
// echo '<img src="$filename">';die; //简单二维码
$logo = 'logo.jpg';//需要显示在二维码中的Logo图像
$QR = $filename;
$QRlogo = 'merge'.time().'png';
if ($logo !== FALSE) {
$QR = imagecreatefromstring ( file_get_contents ( $QR ) );//目标图象连接资源。
$logo = imagecreatefromstring ( file_get_contents ( $logo ) );//源图象连接资源。
$QR_width = imagesx($QR); //二维码图片宽度
$QR_height = imagesy($QR); //二维码图片高度
$logo_width = imagesx($logo); //logo图片宽度
$logo_height = imagesy($logo); //logo图片高度
$logo_qr_width = $QR_width / 4; //组合之后logo的宽度(占二维码的1/5)
$scale = $logo_width/$logo_qr_width; //logo的宽度缩放比(本身宽度/组合后的宽度)
$logo_qr_height = $logo_height/$scale; //组合之后logo的高度
$from_width = ($QR_width - $logo_qr_width) / 2; //组合之后logo左上角所在坐标点
//重新组合图片并调整大小
//imagecopyresampled() 将一幅图像(源图象)中的一块正方形区域拷贝到另一个图像中
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,$logo_qr_height, $logo_width, $logo_height);
imagepng ( $QR, $QRlogo);//带Logo二维码的文件名
}
// echo '<img src="'.$QRlogo.'">';die; //中间有logo
$res = (new Upload())->uploadImg($QRlogo);//上传七牛云
echo $res;die;
// return $res;