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']) ;}}?>