This is a simple way I have determined I can use python to create a QR code.
Quick steps I have used: https://medium.com/@rahulmallah785671/create-qr-code-by-using-python-23….
TODO Next time paste code here
Install python3
You must have python and pip installed
Install requirements
This example requires a library called reportlab
-
pip install reportlab==3.5.48
Run python scipt
The following code will generate a single QR code which links to this page. It is output as both a pdf and png file.
-
print("Start")
-
-
from reportlab.graphics.barcode import qr
-
from reportlab.graphics.shapes import Drawing
-
-
qrcodeText=" https://code.metcarob.com/node/289 "
-
qrcodeText=qrcodeText.strip()
-
-
qr_code = qr.QrCodeWidget(qrcodeText)
-
-
bounds = qr_code.getBounds()
-
width = bounds[2] - bounds[0]
-
height = bounds[3] - bounds[1]
-
x = 4000
-
drawing = Drawing(x, x, transform=[float(x)/width, 0, 0, float(x)/height, 0, 0])
-
drawing.add(qr_code)
-
-
-
drawing.save(
-
formats=["pdf", "png"], verbose=None, fnRoot='OutputQRCode', outDir=None, title='ExampleQRCode'
-
)
-
-
-
print("End")
You can change the value of x to change the resolution of the output image.
reportlabs has not got good documentation. I found this page useful in working out what save did: https://pydoc.net/reportlab/3.3.0/reportlab.graphics.shapes/
This is their main site https://www.reportlab.com/
(I am using their opensource python library)