PHP under the QRCode class library to create the center with the logo of the two-dimensional code _php instance

Source: Internet
Author: User
Tags php class

We want to generate two-dimensional code need to use a number of class libraries to achieve, I introduce the PHP QR code to generate two-dimensional code bar, the generation method is very simple, I would like to introduce the following.

PHP class library using PHP QR code to implement, do not need to install additional PHP extensions, first download the class library package, and sometimes address can not open, address: http://phpqrcode.sourceforge.net/

Download:
Domestic Download: http://www.jb51.net/codes/189897.html
Download abroad: http://sourceforge.net/projects/phpqrcode/

example, create a two-dimensional code using the PHP QR code class library.

1, browser output:

? 
Include "phpqrcode/phpqrcode.php"; 
$value = "Http://www.jb51.net"; 
$errorCorrectionLevel = "L"; 
$matrixPointSize = "4"; 
QRCode::p ng ($value, False, $errorCorrectionLevel, $matrixPointSize); 
Exit; 
? >

2, file output two-dimensional code

Include (' phpqrcode/phpqrcode.php '); 
Two-dimensional code data 
$data = ' http://www.jb51.net '; 
The generated filename 
$filename = ' 1111.png '; 
Error correction level: L, M, Q, H 
$errorCorrectionLevel = ' l '; 
The size of the point: 1 to ten 
$matrixPointSize = 4; 
QRCode::p ng ($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);

3, generate the middle with a logo two-dimensional code

 <?php include (' phpqrcode/phpqrcode.php '); 
$value = ' http://www.jb51.net '; 
$errorCorrectionLevel = ' L '; 
$matrixPointSize = 6; 
QRCode::p ng ($value, ' xiangyang.png ', $errorCorrectionLevel, $matrixPointSize, 2); echo "QR code generated". 
<br/> "; 
$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 '); ? 

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.