Php qr code identification method (php-zbarcode installation and use), phpphp-zbarcode

Source: Internet
Author: User
Tags imagemagick

Php qr code identification method (php-zbarcode installation and use), phpphp-zbarcode

This article describes how to identify the QR code in PHP. We will share this with you for your reference. The details are as follows:

Note: The extension depends on ImageMagick and zbar. Install the two software before installation.

1. Install ImageMagick (http://www.imagemagick.org /)

yum install ImageMagick.x86_64 ImageMagick-devel.x86_64

2. Installing zbar (http://sourceforge.net/projects/zbar? Source = directory)

Wget http://jaist.dl.sourceforge.net/project/zbar/zbar/0.10/zbar-0.10.tar.bz2tar jxvf zbar-0.10.tar.bz2cd zbar-0.10 # note that this step has a big pitfall, to prohibit gtk, python and qt support, or you will be waiting for unlimited error. /configure -- without-gtk -- without-python -- without-qt -- prefix =/usr/local/zbarmake & make install # The prompt is as follows, # make [2]: Leaving directory '/root/zbar-0.10' # make [1]: leaving directory '/root/zbar-0.10' # echo '/usr/local/zbar/lib/'>/etc/ld. so. conf ldconfig ln-s/usr/local/zbar/lib/pkgconfig/zbar. pc/usr/lib64/pkgconfig/zbar. pc

3. install php-zbarcode (https://github.com/mkoppanen/php-zbarcode)

Unzip php-zbarcode-master.zipcd php-zbarcode-master/usr/local/php/bin/phpize. /configure -- with-php-config =/usr/local/php/bin/php-configmake & make install # The following prompt is displayed: # Build complete. # Don't forget to run 'make test '. # Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

4. Add extension = zbarcode. so to the php. ini configuration file.

View phpinfo (); then search for zbarcode.

5. Test Results

Picture taken from https://en.wikipedia.org/wiki/File:Ean-13-5901234123457.png

In addition, you can use the QR code generation tool on this site to generate QR code images for testing:
Http://tools.jb51.net/transcoding/jb51qrcode

The test code is as follows:

<? Php // create an image object $ image = new ZBarCodeImage (". /test.png "); // create a QR code identification tool $ scheme = new zbarcode.pdf (); // recognizes an image $ barcode = $ scheme-> scan ($ image ); // cyclically output the QR code information if (! Empty ($ barcode) {foreach ($ barcode as $ code) {printf ("Found type % s barcode with data % s \ n", $ code ['type'], $ code ['data']) ;}}?>

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.