tp合成二维码海报

一.生成二维码
header('Content-Type:text/html;charset=UTF-8');
$_var_26 = '';
$url = $_var_26 . '/app/index/qudao.html?uid=' . base64_encode($_var_23);
Loader::import('phpqrcode.phpqrcode',EXTEND_PATH,'.php');//Loader::import('phpqrcode.phpqrcode',EXTEND_PATH,'.php');
$errorCorrectionLevel = 'H';//容错级别
$matrixPointSize = 12;//图片大小慢慢自己调整,只要是int就行
$path = './public/uploads/qrcode/';
$QR = $QRB = $path . rand(10000, 99999) . time() . ".png";
\QRcode::png($url, $QR, $errorCorrectionLevel, $matrixPointSize, 2);
二.二维码与logo合成
$QR = imagecreatefromstring(file_get_contents($QR));
$logo = "./logo1.png";
$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 / 3;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($QR_width - $logo_qr_width) / 2;
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
    $logo_qr_height, $logo_width, $logo_height);
$QIMG = $path . rand(100000, 999999) . time() . ".png";
imagepng($QR, $QIMG);
三.将第二步生成的图片与背景图合并
$dst_path = './public/bj.png';   //背景图片路径
$src_path = $QIMG;//覆盖图
//创建图片的实例
$dst = imagecreatefromstring(file_get_contents($dst_path));
$src = imagecreatefromstring(file_get_contents($src_path));
//获取覆盖图图片的宽高
list($src_w, $src_h) = getimagesize($src_path);
//将覆盖图复制到目标图片上,最后个参数100是设置透明度(100是不透明),这里实现不透明效果
imagecopymerge($dst, $src, 105, 815, 0, 0, 800, 436, 100);
@unlink($QIMG);
@unlink($QRB);  //删除服务器上二维码图片
header("Content-type: image/png");
imagepng($dst, './public/uploads/qrcode/' . $_var_23 . '.png');//根据需要生成相应的图片
imagedestroy($dst);
imagedestroy($src);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

php_lidong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值