STUDY WHILE YOU ARE BORING


  • 首頁

  • 搜索

  • 技术

  • Tags

  • 关于我

Centos 6.x 上安装php 的 zbarcode 扩展

發表於 May 27, 2019   |   作者: Tim   |   分类: 技术   |   评论

环境

Centos 6.x
PHP 5.3.3

安装

1 安装ImageMagick依赖

yum install ImageMagick ImageMagick-devel

2 安装zbar拓展

wget -c 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-python --without-qt --prefix=/usr/local/zbar ##禁止gtk,python和qt的支持
make && make install

3 安装php-devel

yum install php-devel

4 安装php-zbarcode

git clone https://github.com/mkoppanen/php-zbarcode.git 
cd php-zbarcode
/usr/bin/phpize #自己phpize的位置
./configure --with-php-config=/usr/bin/php-config --with-zbarcode=/usr/local/zbar/
make && make install

5 添加extension=zbarcode.so 到php.ini中 然后重启apache

6 测试

    //新建一个图像对象  
    $image = new ZBarCodeImage("test.png");  

    // 创建一个二维码识别器  
    $scanner = new ZBarCodeScanner();  

    //识别图像  
    $barcode = $scanner->scan($image);  

    //循环输出二维码信息  
    if (!empty($barcode)) {  
        foreach ($barcode as $code) {  
            echo $code['type'];//图像的条码类型
            echo $code['data'];//条码的数据 
        }  
    }  

参考资料

  1. http://www.geekso.com/qrcode/
  2. http://www.xianyunyehe.cc/2017/03-29/php%E8%AF%86%E5%88%AB%E6%9D%A1%E7%A0%81.html
php, centos, zbarcode
搭建mutt+msmtp发信服务
underconstruct.io a free and none-hosting solution for under construction page

钜添

54 文章
2 分類
1 页面
GitHub 日记技术
php apache centos macos mysql https shadowsocks mac 微信 ups svn javascript outline accesskey Chrome Extension letsencrypt ssl free certification certbo wildcard renew cloudflare pgsql 归档 binlog isset array_key_exists redmine axure
© 2021 钜添   |   文章 RSS     |  登录
由 Typecho 强力驱动
主題 - NexT
Send message encrypted and private - Msg2
Build your Under Construction Page without hosting - UnderConstruct.IO