Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python QR code libraries encode text or a URL as a QR code and write it out as an image, a vector file, or terminal text. An encoder builds the grid of dark and light modules before a serializer draws it. These libraries let apps print payment links, tickets, and sign-in codes that a phone camera can scan.
Popularity
qrcode has the most monthly downloads in this comparison, at 36.3M.
def qr_code(
data, optimize=20, fill_color="black", back_color="white", **qr_code_params
):
"""Return a QR code's image data.
Powered by the Python library ``qrcode``. See this library's documentation
for more details.
Parameters
---------- data
Data to be encoded in the QR code.
optimize
Chunk length optimization setting.
fill_color, back_color
Colors to use for QRcode and its background.
**qr_code_params
Parameters of the ``qrcode.QRCode`` constructor, such as ``version``,
``error_correction``, ``box_size``, ``border``.
Returns
------- image_base64_data
A string ``data:image/png;base64,xxxxxxxxx`` which you can provide as a
"src" parameter to a ``<img/>`` tag.
Examples
-------- >>> data = qr_code('egf45728')
>>> html_data = '<img src="%s"/>' % data
"""
params = dict(box_size=5, border=0)
params.update(qr_code_params)
qr = qrcode.QRCode(**params)
qr.add_data(data, optimize=20)
qri = qr.make_image(fill_color=fill_color, back_color=back_color)
return pil_to_html_imgdata(qri.get_image())
Segno
Creates QR and Micro QR symbols with dependency-free vector and raster serializers.
Downloads / mo
12.0M
Stars
823
Last release
1.6.6
License
BSD-3-Clause
Strengths
Generates Micro QR symbols.Create compact symbols or explicitly require standard QR output.
Exports without image dependencies.Write SVG, PNG, and PDF using the included serializers.
Limitations
Small payloads can become Micro.Use make_qr or micro=False when the receiving system requires standard QR.
Error correction can increase automatically.Disable boost_error when the selected error correction level must remain unchanged.
@validate_call(config=PYDANTIC_CONFIG)
def make_qr(data: Any, qr_code_options: QRCodeOptions, force_text: bool = True):
"""Creates a QR code that encodes the given `data` with the given `qr_code_options`.
:param str data: The data to encode
:param qr_code_options: Options to create and serialize the QR code.
:param bool force_text: Tells whether we want to force the `data` to be considered as text string and encoded in byte mode.
:rtype: segno.QRCode
"""
# WARNING: For compatibility reasons, we still allow to pass __proxy__ class (lazy string). Moreover, it would be # OK to pass anything that has __str__ attribute (e.g. class instance that handles phone numbers). if force_text:
return segno.make(str(data), **qr_code_options.kw_make(), mode="byte")
return segno.make(data, **qr_code_options.kw_make())
PyQRCode
Generates QR codes in pure Python with SVG, EPS, PNG, and terminal output.
def _qrgen(data: Union[bytes, Sequence[int]]) -> "QrCode":
ret = None
V = QrCode.Ecc
for e in [V.HIGH, V.QUARTILE, V.MEDIUM, V.LOW]:
qr = QrCode.encode_binary(data, e)
qr.size = qr._size
qr.modules = qr._modules
if not ret or ret.size > qr.size:
ret = qr
return ret
FAQ
qrcode suits applications that style QR modules and embed images through image factories. Segno suits code that needs Micro QR symbols or SVG, PNG, and PDF output without other dependencies. Treepoem suits systems that render QR codes alongside other barcode formats.
Segno is a pure Python QR Code and Micro QR Code generator with no dependencies. It writes SVG, PNG, PDF, and other formats through its own serializers.
qrcode builds a code through its QRCode class and encodes it as an SVG or PNG image. Segno writes the same kind of code to SVG, PNG, or PDF without image dependencies.
qrcode does not guarantee that styled codes work with all readers. Its documentation recommends testing them and setting error correction to high, especially when embedding an image.
Segno's default factory picks the smallest version that fits the content, including Micro QR versions. The make_qr function requires a standard QR code instead.
For coding agents
Found your QR code library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.