Two-dimensional code picture save path
$pathname = Date ("Ymd", Time ());
$pathname = "./qrcode/". $pathname;
if (!is_dir ($pathname)) {//If the directory does not exist then create the
mkdir ($pathname);
}
Vendor ("Phpqrcode.phpqrcode");
QR Code URL parameter
$text = "http://www.baidu.com";
QR Code picture Save path (set to False if no file is generated)
$filename = $pathname. "/qrcode_". Time (). ". png";
Two-dimensional code fault tolerance, default L
$level = "L";
Two-dimensional code picture pixels per black point, default 4
$size = ' 10 ';
Two-dimensional code border spacing, default 2
$padding = 2;
Save the QR code image and display it, $filename must pass the file path
$saveandprint = true;
Generate two-dimensional code images
QRCode::p ng ($text, $filename, $level, $size, $padding, $saveandprint);
Two-dimensional Code 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);
thinkphp using Phpqrcode to generate a QR code with logo