Due to the need to parse the two-dimensional code image, the operating environment is Centos7.2,python version is 2.7.5, because Zbar only support to Python2.6, so prepare to use the source code compiled installation method. The steps are as follows:
1. Install dependent packages
Yum install pdftk ImageMagick imagemagick-devel Ghostscript python-imaging python-devel
2. Download the source package in http://zbar.sourceforge.NET/download.html
3, the Decompression method is:
Tar -jxvf zbar-0.10.tar.bz2
4, to compile
./configure--WITHOUT-GTK--WITHOUT-QT--disable-video--prefix=/usr/local
5. Installation
Make && make install
6, download Zbar source code, and install, download address https://pypi.python.org/pypi/zbar/0.10
7. Unzip the TAR package
TAR-ZXVF zbar-0.10.tar.gz
8. Installation
Python setup.py Install
10, determine whether the Zbar package is installed successfully, if there is no error, that is, installation success
11, Test Zbar parsing two-dimensional code image
#-*-Coding:utf-8-*-import zbarfrom PIL import image# Create picture Scan object scanner = Zbar. Imagescanner () # Set object Properties Scanner.parse_config (' Enable ') # Open the picture containing the QR code img = Image.open (' < your picture path > '). Convert (' L ') # To get the size of the picture width, height = img.size# Create Zbar Picture object and Scan to convert to byte information QRCode = Zbar. Image (width, height, ' Y800 ', Img.tobytes ()) Scanner.scan (qrcode) data = "for S" QRCode: data + = s.data# Delete Picture Object del img # Output decoding result print data