Thinkphp3.2 version combined with Phpqrcode to generate a QR code with logo and download

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.