sudo apt install python-pip
sudo pip install image
sudo pip install qrcode
sudo pip install fonts
sudo apt-get install ttf-mscorefonts-installer
To test using imagemagick
sudo apt install imagemagick
Python code: test.py
from PIL import Image, ImageDraw,ImageFont
import qrcode
qr = qrcode.QRCode(
version=3,
error_correction=qrcode. constants.ERROR_CORRECT_Q,
box_size=10,
border=4,
)
image = Image.new( "RGBA", ( 410, 480 ) ,"white");
qr.add_data('https://example. com/stuff/rack/1')
qr.make(fit=True)
img = qr.make_image()
print img.size
image.paste(img, (0,0), img.convert("RGBA") );
draw = ImageDraw.Draw(image)
font = ImageFont.truetype("/usr/lib/ cinelerra/fonts/arial.ttf",60)
#font = ImageFont.load_default()
txt = "rack 1"
draw.text((100, 410), txt, (0,0,0), font=font)
image.save("qr.png")
import qrcode
qr = qrcode.QRCode(
version=3,
error_correction=qrcode.
box_size=10,
border=4,
)
image = Image.new( "RGBA", ( 410, 480 ) ,"white");
qr.add_data('https://example.
qr.make(fit=True)
img = qr.make_image()
print img.size
image.paste(img, (0,0), img.convert("RGBA") );
draw = ImageDraw.Draw(image)
font = ImageFont.truetype("/usr/lib/
#font = ImageFont.load_default()
txt = "rack 1"
draw.text((100, 410), txt, (0,0,0), font=font)
image.save("qr.png")
To run:
python test.py
display qr.png