With this code you can generate a QR code to help you access links more easily. You can set a custom image containing the QR code and show it to anyone who wants to access the link.
Installation:
- At “URL” set up your image that you want to have it on the QR
- qr.add_data(“your link”) here you put the link for your QR (where you want to be redirected scanning the QR code)
Code:
import qrcode
from PIL import Image
import requests
url = 'IMAGE FOR YOU'
response = requests.get(url, stream = True)
face = Image.open(response.raw)
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data('YOUR LINK')
qr.make(fit=True)
img_qr_big = qr.make_image(fill_color="yellow", back_color="black").convert('RGB')
pos = ((img_qr_big.size[0] - face.size[0]) // 2, (img_qr_big.size[1] - face.size[1]) // 2)
img_qr_big.paste(face, pos)
img_qr_big.save('data/src/qr_lena2.png')