引用http://www.jb51.net/article/48124.htm 主要区别已变色
$errorCorrectionLevel = intval($level); //容错级别
$matrixPointSize = intval($size); //生成图片大小$object = new \QRcode();
//缓存区存放
ob_start();
$object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
$ob_contents = ob_get_contents(); //读取缓存区数据
ob_end_clean();
//logo 文件
$logo = 'logo.png';
//logo图片存在
if ($logo !== FALSE) {
//$qrcode = imagecreatefromstring(file_get_contents($qrcode));
$qrcode = imagecreatefromstring($ob_contents);
$logo = imagecreatefromstring(file_get_contents($logo));
$qrcode_width = imagesx($qrcode); //二维码图片宽度
$qrcode_height = imagesy($qrcode); //二维码图片高度
$logo_width = imagesx($logo); //logo图片宽度
$logo_height = imagesy($logo); //logo图片高度
$logo_qr_width = $qrcode_width / 5;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($qrcode_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($qrcode, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
$logo_qr_height, $logo_width, $logo_height);
}
Header("Content-type: image/png");
imagepng($qrcode);