import qrcode
from PIL import Image
# Generate QR code for a URL
url = "https://www.clcoding.com"
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=8, border=5)
qr.add_data(url)
qr.make(fit=True)
# Create an image with logo
image = qr.make_image(fill_color="black", back_color="pink")
# Add logo to the QR code
logo = Image.open("clcodinglogo.png")
logo_size = img.size[0] // 4
# Use Image.LANCZOS for resizing with anti-aliasing
logo = logo.resize((logo_size, logo_size), Image.LANCZOS)
image.paste(logo, ((img.size[0] - logo.size[0]) // 2, (img.size[1] - logo.size[1]) // 2))
# Save the image
image.save("qr_code.png")
Image.open("qr_code.png")
0 Comments:
Post a Comment