PHP Identification of two-dimensional code method (Php-zbarcode installation and use) _php skills

Source: Internet
Author: User

This article illustrates the method of PHP to recognize two-dimensional code. Share to everyone for your reference, specific as follows:

Description: The extension needs to rely on ImageMagick and Zbar, install the two software before installation

1. Installation of ImageMagick (http://www.imagemagick.org/)

Yum Install imagemagick.x86_64 imagemagick-devel.x86_64

2. Installation of 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 be waiting for an unlimited 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. Installation of 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 to 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 configuration file

View Phpinfo () at this time, after searching Zbarcode to complete

5. Test effect

Pictures taken from Yun_qi_img/ean-13-5901234123457.png

In addition, the user can also use the station two-dimensional code generation tool to generate two-dimensional code pictures to test:
Http://tools.jb51.net/transcoding/jb51qrcode

The test code is as follows:

<?php
  //Create a new Image object
  $image = new Zbarcodeimage ("./test.png");
  Create a two-dimensional code recognizer
  $scanner = new Zbarcodescanner ();
  Recognition of image
  $barcode = $scanner->scan ($image);
  Circular output two-dimensional code information
  if (!empty ($barcode)) {
    foreach ($barcode as $code) {
      printf ("Found type%s barcode with data%s\ n ", $code [' type '], $code [' data ']);
    }
? >

For more information on PHP related content readers can view the site topics: "PHP graphics and pictures Operating skills summary", "PHP array Operation techniques Encyclopedia", "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Mathematical Calculation Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.