Do not do too much description, the detailed content can refer to the article "Thinkphp3.2 version combined with Phpqrcode to generate two-dimensional code and provide download."
The method is to replace the QRCode () method with the QICODE_MH () method, and the path can be configured by itself.
Generate QR code-beautify version public function qrcode_mh ($url, $name) {Ob_clean (); Vendor (' Phpqrcode.phpqrcode '); $level = 3; $size = 4; $errorCorrectionLevel = Intval ($level);//fault tolerance level $matrixPointSize = Intval ($size);//Generate picture size//save location $path = "public/home/qrcode/"; The generated file name $fileName = $path. Date (' y-m-d ', Time ()). " -". $name." PNG '; Generate QR code image $object = new \qrcode (); $object->png ($url, $fileName, $errorCorrectionLevel, $matrixPointSize, 2); Ob_clean (); $QR = $fileName;//The original two-dimensional code graph that has been generated $logo = "public/home/xiao/". Rand (1,5). PNG "///Ready logo image if (file_exists ($logo)) {$QR = Imagecreatefromstring (file_get_contents ($QR)); $logo = imagecreatefromstring (file_get_contents ($logo)); $QR _width = Imagesx ($QR);//QR code image width $QR _height = Imagesy ($QR);//QR code image height $logo _width = imagesx ($logo); Logo image width $logo _height = Imagesy ($logo);//logo Picture Highdegree $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; Regroup and resize the picture imagecopyresampled ($QR, $logo, $from _width, $from _width, 0, 0, $logo _qr_width, $logo _q R_height, $logo _width, $logo _height); Output image Header ("Content-type:image/png"); Dump ($qrcode _path); $qrcode _path = $path. Date (' y-m-d ', Time ()). " -". $name." PNG '; Imagepng ($QR, $qrcode _path); Imagedestroy ($QR); return $qrcode _path; }else{return false; } }
Thinkphp3.2 version combined with Phpqrcode to generate a QR code with logo and download