Menu
QR Code Generator
Make QR-Code using Python
- We make QR-Code very easily.
- We need two packages to make it.
We need two packages, let's install at first
pip install qrcode
also install
pip install pillow
We use qrcode for making QR-Code and pillow to allow image generation.
At first we make a simple QR
Inside a directory, write and run this code:
import qrcode
myqr = qrcode.make("https://debojyotitantra.vercel.app") # making a QR
myqr.save("myqr.png") # save the QR
After running this code, a myqr.png file will be created containing the QR code.
myqr.png
Scan this QR code to visit: https://debojyotitantra.vercel.app
Make QR adding custom parameters
import qrcode
# Create an instance of the QRCode class
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=8,
border=3,
)
# Add the data to the QR code
qr.add_data("https://debojyotitantra.vercel.app")
qr.make(fit=True)
# Create and save the image
img = qr.make_image(fill='black', back_color='white')
img.save("myqr.png")
That's how we can create a QRCode with custom parameters.
Feel free to experiment with the parameters to change the size, error correction, and design.
No comments yet. Be the first to comment!