atjs

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

最后验证结果即可;

分类:

技术点:

相关文章:

  • 2021-09-20
  • 2021-09-07
  • 2022-12-23
  • 2022-01-02
  • 2021-08-14
  • 2021-11-21
  • 2023-04-06
  • 2021-11-21
猜你喜欢
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-05-18
  • 2021-12-20
相关资源
相似解决方案