JAYSON

I'm a developer.

导航

PHP识别二维码功能,php-zbarcode 安装

php-zbarcode是PHP识别二维码的扩展。

下面是安装方法,安装前要先安装ImageMagick、zbar.

 

php-zbarcode 下载地址

 

安装ImageMagick:

yum install ImageMagick.x86_64 ImageMagick-devel.x86_64
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
./configure –without-gtk –without-qt –without-python –prefix=/usr/local/zbar
make all
make install
echo “/usr/local/zbar/lib/” >> /etc/ld.so.conf
ldconfig
ln -s /usr/local/zbar/lib/pkgconfig/zbar.pc  /usr/lib64/pkgconfig/zbar.pc
wget https://github.com/lgchgt/php-zbarcode/archive/master.zip
unzip master
cd php-zbarcode-master
/xxx/server/php/bin/phpze
/configure –with-php-config=/xxx/server/php/bin/php-config
make
make install
ll /xxx/server/php/lib/php/extensions/no-debug-non-zts-20100525/

添加:extension=zbarcode.so 到php.ini配置文件
运行 : php -i|grep zbar


检查是否安装功能

<?php
/* Create new image object */
$image = new ZBarCodeImage(“1.jpg”);
$scanner = new ZBarCodeScanner();
$barcode = $scanner->scan($image);
print_r($barcode);
/* Loop through possible barcodes */ if (!empty($barcode)) {   foreach ($barcode as $code) {     printf(“Found type %s barcode with data %s\n”, $code[‘type’], $code[‘data’]);   } }

最后验证结果即可;

posted on 2015-12-30 12:54  金一山  阅读(2172)  评论(0编辑  收藏  举报