Using Phpqrcode to generate two-dimensional code instance code

Source: Internet
Author: User

QR Code detailed principle can refer to QR Wikipedia, the Chinese version introduction is relatively few, the English version introduction is very comprehensive, the recommendation looks English edition.

Description

The PHP QR Code is the Open source (LGPL) library for generating QR code, 2-dimensional barcode. Based on Libqrencode C Library, provides APIs for creating QR Code barcode Images (PNG, JPEG-to GD2). Implemented purely in PHP.

Features

supports QR Code versions (size) 1-40

numeric, alphanumeric, 8-bit and kanji encoding.

implemented purely in PHP, no external dependencies except GD2

exports to PNG, JPEG images, also exports as bit-table

tcpdf 2-d Barcode API Integration

Easy to configure

data cache for calculation speed-up

Debug data dump, error logging, Time benchmarking

provided merge tool helps deploy library as a one file

new! API Documentation

new! Over detailed examples

100% Open Source, LGPL licensed

Demo

Project Address: http://sourceforge.net/projects/phpqrcode/

Generate Fixed size images

* Phpqrcode itself does not provide a fixed size two-dimensional code settings, please refer to the http://sourceforge.net/p/phpqrcode/discussion/1111884/thread/f739531a/

  code as follows  

---original/phpqrcode/qrimage.php        2010-08-18 07:06:24.000000000-0700
+++ qrimage.php 2012-07-13 00:51:57.000000000-0700
@@ -86,10 +86,15 @@
                }
            }
-            $target _image =imagecreate ($imgW * $ Pixelperpoint, $imgH * $pixelPerPoint);
-            imagecopyresized ($target _image, $base _ Image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH);
+
+            $targetW = (defined (' Image_width ')? ImaGe_width: $imgW * $pixelPerPoint);
+            $targetH = (defined (' Image_height ')? Image_height: $imgH * $pixelPerPoint);
+
+            $target _image =imagecreate ($targetW , $targetH);
+
+            imagecopyresized ($target _image, $ Base_image, 0, 0, 0, 0, $targetW, $targetH, $imgW, $imgH);
             Imagedestroy ($base _image);
             return $target _image;
        }
-   }
No newline at end of file
+   }

Use to set the generated two-dimensional code width to 500px

Define (' Image_width ', 500);
define (' Image_height ', 500);
QRCode::p ng (' http://www.111cn.net/) ');

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.