PHP identification QR code (PHP-ZBARCODE)Tags: php two-dimensional code extension2015-11-06 17:12 609 People read comments (0) favorite reports Classification:PHP (1)Linux
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Description: Extensions need to rely on ImageMagick and Zbar to install both software 1 before installation. Installation ImageMagick (http://www.imagemagick.org/) yum Install imagemagick.x86_64 imagemagick-devel.x86_64 2. Installing the Zbar (http://sourceforge.net/projects/zbar/?source= directory) wget http://jaist.dl.sourceforge.net/project/zbar/zbar/0.10/zbar-0.10.tar.bz2 Tar jxvf zbar-0.10.tar.bz2 cd zbar-0.10 #注意此步有大坑, to prohibit Gtk,python and QT support, otherwise you will wait for infinite error./configure-- WITHOUT-GTK--without-python--without-qt--prefix=/usr/local/zbar make && make install #提示如下为完成, Not an error #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. Installing Php-zbarcode (Https://github.com/mkoppanen/php-zbarcode) unzip PHP-ZBARCODE-MASTER.ZIP  CD Php-zbarcode-master /usr/local/php/bin/phpize ./configure-- with-php-config=/usr/Local/php/bin/php-config make && make install #提示如下完成 #build complete. #Don ' t forget-run ' make test ' . #Installing Shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ 4. Add: extension=zbarcode.so to php.ini profile View Phpinfo at this time, after searching Zbarcode for completion 5. Test results pictures taken from https:// En.wikipedia.org/wiki/file:ean-13-5901234123457.png[PHP]View PlainCopy
- <?php
- //Create a new Image object
- $image = new Zbarcodeimage ("./test.png");
- //Create a two-dimensional code recognizer
- $scanner = new Zbarcodescanner ();
- //Image recognition
- $barcode = $scanner->scan ($image);
- //Cyclic output QR code information
- if (! Empty ($barcode)) {
- foreach ($barcode as $code) {
- printf ("Found type%s barcode with Data%s\n", $code [' type '], $code [' data ']);
- }
- }
- ?>
PHP identification QR code (php-zbarcode