Skip to main content

Fast, robust, and less incomplete cffi-based bindings for libqrencode (Py2, Py3, and PyPy)

Project description

Fast, robust, and slightly less incomplete cffi-based Python bindings for libqrencode (http://fukuchi.org/works/qrencode/index.en.html).

Python 2, Python 3, and PyPy compatible!

Installing

$ pip install libqrencode-cffi

Examples

>>> import libqrencode as qr
>>> qrc = qr.QRCode("Hello, world!")

# The raw QR code can be accessed, where each item is a bitfield containing
# information about that portion of the code (see DATA_* constants).
>>> qrc.get_raw_data()
[193, 193, 193, 193, ...  3, 2, 2, 3, 3]

# If PIL is installed, a PIL image of the QR code can be created:
>>> qrc.get_im(border=3)
<PIL.Image.Image image mode=L size=81x81 at ...>

# And if lxml.etree / xml.etree is available, an SVG can be generated:
>>> qrc.get_svg_etree()
<Element g at ...>
>>> qrc.get_svg_string()
'<g><rect fill="white" height="21" width="21" x="0" y="0"/>...<rect fill="black" height="1" width="1" x="20" y="19"/></g>'

Constants

Encoding modes (see https://en.wikipedia.org/wiki/QR_code#Encoding):

  • MODE_NUL (internal to qrencode)

  • MODE_NUM

  • MODE_AN

  • MODE_8 (default)

  • MODE_KANJI

  • MODE_STRUCTURE (not fully supported by libqrencode)

  • MODE_ECI (not fully supported by libqrencode)

  • MODE_FNC1FIRST (not fully supported by libqrencode)

  • MODE_FNC1SECOND (not fully supported by libqrencode)

Error correction modes:

  • ECLEVEL_L (7%; default)

  • ECLEVEL_M (15%)

  • ECLEVEL_Q (25%)

  • ECLEVEL_H (30%)

Raw data bitmasks:

  • DATA_BW (1=black/0=white)

  • DATA_DATA_AND_ECC (data and ecc code area)

  • DATA_FORMAT_INFO (format information)

  • DATA_VERSION_INFO (version information)

  • DATA_TIMING_PATTERN (timing pattern)

  • DATA_ALIGNMENT_PATTERN (alignment pattern)

  • DATA_FINDER_PATTERN (finder pattern and separator)

  • DATA_NON_DATA (non-data modules (format, timing, etc.))

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

libqrencode-cffi-0.1.1.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file libqrencode-cffi-0.1.1.tar.gz.

File metadata

File hashes

Hashes for libqrencode-cffi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 654c214f73b6c5f57e034231e1e8e2ee5c3b3cc83697e4923fc65e7e2319f277
MD5 de138a7dd6616756d4f3e1c9b4d29d49
BLAKE2b-256 9fefa81c45dac542bfb435250f3f8a43f0d07bfb49dedd82a707b51b6065d2ba

See more details on using hashes here.

Provenance

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