Vendor (' Phpqrcode.phpqrcode '); $value = "http://www.baidu.com";//QR code content $errorCorrectionLevel = ' L ';//tolerance level $matrixPointSize = 6;//Generate picture size Generate two-dimensional code picture \qrcode::p ng ($value, ' qrcode.png ', $errorCorrectionLevel, $matrixPointSize, 2); $logo = ' logo15.png ';///Ready logo image $QR = ' qrcode.png ';//The original two-dimensional code diagram already generated if ($logo!== FALSE) {$QR = i Magecreatefromstring (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 image height $logo _qr_width = $QR _width/8; $scale = $logo _width/$logo _qr_width; $logo _qr_height = $logo _height/$scale; $from _width = ($QR _width-$logo _qr_width)/2; Regroup the picture and resize imagecopyresampled ($QR, $logo, $from _width, $from _width, 0, 0, $logo _qr_width, $logo _qr_height, $logo _width, $logo _height); } $path = './public/pay_img/'; if (!is_dir ($path)) {$r = mkdir ($path, 0777, true); if (! $r) {$this->error (' Create folder failed '); }}//Output picture imagepng ($QR, MD5 (Time ()). PNG '); $file = './'. MD5 (Time ()). PNG '; Old directory $newFile = $path. MD5 (Time ()). PNG '; New directory Copy ($file, $newFile); Copy to the new directory unlink ($file); Delete the file under the old directory $path = substr ($path, 1); $IMGSRC = $path. MD5 (Time ()). ". PNG ";
Two-dimensional code class https://pan.baidu.com/s/1c2zB5D2
PHP TP generates two-dimensional code