Generate QR Code using qrcode module

QR code, or Quick Response code, is a two-dimensional barcode that can be scanned using a smartphone camera or QR code reader. These codes can contain a variety of information, including text, URLs, contact information, and even entire documents. QR codes are commonly used for a variety of purposes, including marketing and advertising, product tracking, and as a quick and easy way to access information or navigate to a website. They are particularly popular in the retail and e-commerce industries, as they allow customers to easily access product information, reviews, and special deals. QR codes are also frequently used in events, such as conferences, to provide attendees with information about the schedule, speakers, and location. With the increasing use of smartphones, QR codes have become a quick and convenient way for businesses and individuals to share information and connect with customers.

pip install qrcode
pip install Pillow
import qrcode

# Create a QR code object with a larger size and higher error correction
qr = qrcode.QRCode(version=3, box_size=20, border=10, error_correction=qrcode.constants.ERROR_CORRECT_H)

# Define the data to be encoded in the QR code
data = "https://medium.com/@rahulmallah785671/create-qr-code-by-using-python-2370d7bd9b8d"

# Add the data to the QR code object
qr.add_data(data)

# Make the QR code
qr.make(fit=True)

# Create an image from the QR code with a black fill color and white background
img = qr.make_image(fill_color="black", back_color="white")

# Save the QR code image
img.save("qr_code.png")

# Size, Color and Border of Qrcode

from PIL import Image
import qrcode

# Create a QR code object
qr = qrcode.QRCode(version=1, box_size=10, border=5)

# Define the data to be encoded in the QR code
data = "https://www.example.com"

# Add the data to the QR code object
qr.add_data(data)

# Make the QR code
qr.make(fit=True)

# Create an image from the QR code
img = qr.make_image(fill_color="red", back_color="white")

# Open the logo or image file
# logo = Image.open("logo.png")
logo = img.save("logo.png")

 

 

Leave a Reply