Skip to main content

fastzbarlight is a fork of zbarlight which ships with its own vendored libzbar, which it compiles with optimization flags to make it faster than the stock Ubuntu version. Try out the simple “trial.py” benchmark in this repository:

` $ python trial.py Average call time with zbarlight: 2.0961521719982557ms (1000 tries) Average call time with fastzbarlight: 0.7335694559988042ms (1000 tries) `

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.

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())

Release files for fastzbarlight 0.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastzbarlight 0.0.14
File Size Uploaded
fastzbarlight-0.0.14.tar.gz 728.4 kB Details

Release files / fastzbarlight-0.0.14.tar.gz

Download URL fastzbarlight-0.0.14.tar.gz
Size 728.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d420b0049ef3cde54633aa6a37d4f4607f11802c72ba6646f5fb376f198165b9
BLAKE2b-256 checksum
How to use checksums
2bf6b46fe453ab12ac08c6a15808d402963819f26d4bd9daa5a899f6a3bae22d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.14 This release

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page