<?php require_once 'phpqrcode.php'; QRcode::png('http://www.baidu.com', 'filename.png',QR_ECLEVEL_L,100); // creates file $QR = imagecreatefrompng("filename.png"); $logo = imagecreatefrompng("logo.png"); var_dump($QR); var_dump($logo); $QR_width = imagesx($QR); $QR_height = imagesy($QR); //echo $QR_width; //echo $QR_height; $logo_width = imagesx($logo); $logo_height = imagesy($logo); //echo $logo_width; //echo $logo_height; // Scale logo to fit in the QR Code $logo_qr_width = $QR_width/9; $scale = $logo_width/$logo_qr_width; $logo_qr_height = $logo_height/$scale; $from_width = ($QR_width-$logo_qr_width)/2; //echo $from_width;exit; imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height); imagepng($QR,'last.png');
如果是输出到浏览器上 把最好一句改成imagepng($QR);
具体在附件上