add gdimage output
maybe the qrPngLogo could be added somewhere too ? the idea is to produce image with logo.
?php require_once("phpqrcode/qrlib.php");
//$QR = QRcode::png($_GET["url"], false, QR_ECLEVEL_H, 20, 1, true); //exit(0);
qrPngLogo($_GET["url"], "logo.jpg", QR_ECLEVEL_H, 20, 1, 4, true);
function qrPngLogo($text, $logopath, $level, $size, $margin, $logo_ratio, $print = false) { $QR = QRcode::gdimage($text, $level, $size, $margin);
if( ($data = file_get_contents($logopath)) === false) throw new Exception("unable to read logo");
if( ($logo = imagecreatefromstring($data)) === false) throw new Exception("unable to read logo");
$QR_width = imagesx($QR); $QR_height = imagesy($QR); $logo_width = imagesx($logo); $logo_height = imagesy($logo); if($QR_width === false || $QR_height === false || $logo_width === false || $logo_height === false) throw new Exception("unable to read image size");
$logo_qr_width = $QR_width/$logo_ratio; $scale = $logo_width/$logo_qr_width; $logo_qr_height = $logo_height/$scale;
if(imagecopyresampled($QR, $logo, $QR_width/2-$logo_qr_width/2, $QR_height/2-$logo_qr_height/2, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height) === false) throw new Exception("unable to write the logo"); ImageDestroy($logo);
if($print) { header ('Content-Type: image/png'); imagepng($QR); ImageDestroy($QR); } else { return $QR; } } ?