Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

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 (

Python 2, Python 3, and PyPy compatible!


$ pip install libqrencode-cffi


>>> 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>'


Encoding modes (see

  • MODE_NUL (internal to qrencode)
  • MODE_8 (default)
  • 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.))

Release History

This version
History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(9.2 kB) Copy SHA256 Hash SHA256
Source None Jul 17, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers