Home > Backend Development > PHP Tutorial > 使用PHP QRcode生成二维码广告图

使用PHP QRcode生成二维码广告图

WBOY
Release: 2016-06-23 13:09:09
Original
1141 people have browsed it

官方下载地址:

http://phpqrcode.sourceforge.net/

然后就是二维码合并广告图代码:

<?phpinclude 'phpqrcode/phpqrcode.php';		$bgFile = 'Public/wap/images/tg.png';		$qrConf = array(			'data'	=> 'http://www.baidu.com',			'level' => 'L',			'size'	=> 9,			'margin'=> 2		);				$img = imagecreatefrompng($bgFile);		$qrHander = \QRcode::png($qrConf['data'], true, $qrConf['level'], $qrConf['size'], $qrConf['margin']);		$rs = imagecopymerge($img, $qrHander, 230, 700, 0, 0, imagesx($qrHander), imagesy($qrHander), 100);				header("Content-type: image/png");		imagepng($img);
Copy after login



上面代码很简单,就是通来 QRcode::png 来生成一个二维码图并返回图片句柄,然后通过 imagecopymerge 合并一张背景图,如果你直接下载原生的QRcode 类,可能还需要修改里面一点代码, QRcode::png 默认是没有返回句柄的,要么输出,要么生成文件,具体修改如下:

phpqrcode.php 

#3303 前面加 return QRimage::png

#954 ImagePng($image, $filename); 下面加上 return $image;

这样就行了

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template