$qrcodePath=ROOT_PATH.'uploads/qrcode/'.$uid.'.png';//二维码位置
$posterPath=ROOT_PATH.'uploads/qrcode/poster_'.$uid.'.png';//合成邀请图位置
if(!file_exists($posterPath)){
$url='XXXXXXXX';
vendor('wechatpay.phpqrcode.phpqrcode');
$qrcode = new \QRcode;
$pngurl = $url;
$qrcode->png($pngurl,$qrcodePath,'M',10,0);
$this->qrcodeMerge($qrcodePath,$posterPath);
}
function qrcodeMerge($qrcodePath,$posterPath){
$bigImg = imagecreatefromstring(file_get_contents(ROOT_PATH.'public/static/invit.jpg'));//背景图
$qCodeImg = imagecreatefromstring(file_get_contents($qrcodePath));
$newqrcode=imagecreatetruecolor(187, 187);
list($qCodeWidth, $qCodeHight) = getimagesize($qrcodePath);
imagecopyresized($newqrcode, $qCodeImg,0, 0,0, 0,187, 187, $qCodeWidth, $qCodeHight);
list($bgWidth, $bgHight) = getimagesize(ROOT_PATH.'public/static/invit.jpg');
imagecopymerge($bigImg, $newqrcode, 192, 562, 0, 0, 187, 187, 100);
$img = imagejpeg($bigImg, $posterPath);
}2月252021

发表评论