//二維碼圖片保存路徑
$pathname = date("Ymd",time());
$pathname = "./Qrcode/" . $pathname;
if(!is_dir($pathname)) { //若目錄不存在則創建之
mkdir($pathname);
}
vendor("phpqrcode.phpqrcode");
//二維碼URL參數
$text = "http://www.baidu.com";
//二維碼圖片保存路徑(若不生成文件則設置為false)
$filename = $pathname . "/qrcode_" . time() . ".png";
//二維碼容錯率,默認L
$level = "L";
//二維碼圖片每個黑點的像素,默認4
$size = '10';
//二維碼邊框的間距,默認2
$padding = 2;
//保存二維碼圖片並顯示出來,$filename必須傳遞文件路徑
$saveandprint = true;
//生成二維碼圖片
QRcode::png($text,$filename,$level,$size,$padding,$saveandprint);
//二維碼logo
$logo = "./Public/Admin/images/bg1.jpg";
$QR = imagecreatefromstring(file_get_contents($filename));
$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,$filename);
