Python QR Codes

As we stopped wanting to touch each other and things during the Covid-19 pandemic, QR Codes became ubiquitous.

As I'm planning a few upcoming virtual lightning talks at the Cloud-Native Geospatial Outreach Event that include unsightly links, I'm preparing a few QR codes that (hopefully?) the audience will be able to use rather than copy/pasting links during my talks.

Anyway, creating QR codes with Python is easy, thanks to the qrcode module. Here's how I created a QR code pointing to this page:

import qrcode
from qrcode.image.styledpil import StyledPilImage
from qrcode.image.styles.moduledrawers import RoundedModuleDrawer

qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H)
qr.add_data('https://darrenwiens.github.io/python-qr-codes.html')

img = qr.make_image(
    image_factory=StyledPilImage,
    embeded_image_path="/path/to/image.png",
    module_drawer=RoundedModuleDrawer()
)
img.save("qr-code-blog.png")

And the result: qr code

Get in touch with me on Twitter if you want to talk about it!