当前位置:主页 >> PHP >> 正文
phpqrocde集成生成指定路径logo二维码
阅读:609 输入:2019-03-22 11:49:06
include ('phpqrcode/phpqrcode.php');
$data=$_GET["data"];
$pathAndName='code/'.$_GET["name"];//不用扩展名
$logo='file/logo.png';
createQR($data,$pathAndName,$logo);
function createQR($text,$imgName,$logo='',$errorCorrectionLevel = 'L',$matrixPointSize = 10){
	QRcode::png ($text,$imgName.'.png',$errorCorrectionLevel,$matrixPointSize,2);
	if($logo){
		$QR = imagecreatefromstring(file_get_contents($imgName.'.png'));
		$logo = imagecreatefromstring(file_get_contents($logo));
		$QR_width = imagesx($QR);
		$QR_height = imagesy($QR);
		$logo_width = imagesx($logo);
		$logo_height = imagesy($logo);
		$logo_qr_width = $QR_width/5;
		$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 );
		imagepng($QR,$imgName.'.png' );//带Logo二维码
	}//if
}//crate