Use the QRCode class library in PHP to create a QR code with a central website LOGO

Source: Internet
Author: User
This article mainly introduces how to use the QRCode class library in php to create a QR code with a LOGO in the middle, and the example code of QRcode to generate a QR code, if you want to generate a QR Code, you need to use some class libraries to generate the QR Code. The following describes how to generate a QR Code using php qr Code. the method is simple, next I will introduce it.

Using php class library php qr Code to achieve, do not need to install additional php extensions, first download the class library package, sometimes the address cannot open, address: http://phpqrcode.sourceforge.net/

Download:
Domestic Download: http://www.bitsCN.com/codes/189897.html
Foreign Download: http://sourceforge.net/projects/phpqrcode/

Example: Use the php qr Code class library to create a QR Code.

1. browser output:

<? include "phpqrcode/phpqrcode.php"; $value="http://www.bitsCN.com"; $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: // www.jbxue.com'; // generated file name $ filename = '1111.png '; // error correction level: l, M, Q, H $ errorCorrectionLevel = 'l'; // the point size: 1 to 10 $ matrixPointSize = 4; QRcode: png ($ data, $ filename, $ errorCorrectionLevel, $ matrixPointSize, 2 );

3. generate a QR code with a central logo

<?php include('phpqrcode/phpqrcode.php'); $value='http://www.bitsCN.com'; $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'); ?>

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.