Create a QR code with a LOGO in the middle of the PHPQRCode class library
Example: Use the php qr Code class library to create a QR Code. 1. browser output:
- Include "phpqrcode/phpqrcode. php ";
- $ Value = "http://bbs.it-home.org ";
- $ ErrorCorrectionLevel = "L ";
- $ MatrixPointSize = "4 ";
- QRcode: png ($ value, false, $ errorCorrectionLevel, $ matrixPointSize );
- Exit;
- ?>
2. file output QR code
- Include ('phpqrcode/phpqrcode. php ');
- // QR code data
- $ Data = 'http: // bbs.it-home.org ';
- // Generated file name
- $ Filename = '1111.png ';
- // Error correction level: L, M, Q, H
- $ ErrorCorrectionLevel = 'l ';
- // Vertex size: 1 to 10
- $ MatrixPointSize = 4;
- QRcode: png ($ data, $ filename, $ errorCorrectionLevel, $ matrixPointSize, 2 );
3. generate a QR code with a central logo
Include ('phpqrcode/phpqrcode. php ');
- $ Value = 'http: // bbs.it-home.org ';
- $ ErrorCorrectionLevel = 'l ';
- $ MatrixPointSize = 6;
- QRcode: png ($ value, 'xiangyang.png ', $ errorCorrectionLevel, $ matrixPointSize, 2 );
- Echo "QR code generated "."
";
- $ Logo = 'logo.png ';
- $ QR = 'xiangyang.png ';
If ($ logo! = FALSE)
- {
$ QR = imagecreatefromstring (file_get_contents ($ QR ));
- $ 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,'xiangyanglog.png ');
- ?>
|