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
检查是否安装功能
/* 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’]);
}
}
?>

最后验证结果即可;



你可能感兴趣的:(php,qrcode,二维码,识别,读取,WEB开发,PHP)