Skip to main content

A simple zbar wrapper

Project description

ZbarLight

zbarlight is a simple wrapper for the zbar library. For now, it only allows to read QR codes but contributions, suggestions and pull requests are welcome.

zbarlight is compatible with Python 2 and Python 3.

zbarlight is hosted on Github at <https://github.com/Polyconseil/zbarlight/>.

Installation

You need to install ZBar Bar Code Reader <http://zbar.sourceforge.net/> and its headers to use zbarlight:

  • on Debian, apt-get install libzbar0 libzbar-dev

  • on Mac OS X, brew install zbar

Then you should use pip or setuptools to install the zbarlight wrapper.

For Windows installation Instruction For Windows <https://gist.github.com/Zephor5/aea563808d80f488310869b69661f330>.

How To use ZbarLight

The new way:

from PIL import Image
import zbarlight

file_path = './tests/fixtures/two_qr_codes.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()

codes = zbarlight.scan_codes('qrcode', image)
print('QR codes: %s' % codes)

The deprecated way:

from PIL import Image
import zbarlight

file_path = './tests/fixtures/one_qr_code.png'
with open(file_path, 'rb') as image_file:
    image = Image.open(image_file)
    image.load()
converted_image = image.convert('L')  # Convert image to gray scale (8 bits per pixel).
image.close()

raw = converted_image.tobytes()  # Get image data.
width, height = converted_image.size  # Get image size.
code = zbarlight.qr_code_scanner(raw, width, height)

print('QR code: %s' % code.decode())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zbarlight-1.1.0.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file zbarlight-1.1.0.tar.gz.

File metadata

  • Download URL: zbarlight-1.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zbarlight-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ad2c16256faa8e28b8709c9e6c5dabff15c7853c640812a49809894cfba1d5a9
MD5 1ea8daea1758f342b71a126b13a54baf
BLAKE2b-256 f8cc941f0e91fd3ab61e59cb84bd4b13063b658de04d58acc7857b66010cf166

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page