Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions QR Code Generator/QRcode.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import qrcode
from qrcode.constants import ERROR_CORRECT_L

qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L)
qr.add_data("INSERT YOUR LINK HERE")
qr.make(fit=True)
def generate_qrcode(data: str, file_path: str = "qrcode.png", fill_color: str = "black", back_color: str = "white"):
"""
Generates a QR code from the provided data and saves it as an image file.

Parameters:
- data (str): The content the QR code should contain (URL, text, etc.).
- file_path (str): The path to save the QR code image file (default: "qrcode.png").
- fill_color (str): Color of the QR code (default: "black").
- back_color (str): Background color of the QR code (default: "white").
"""
qr = qrcode.QRCode(
version=1,
error_correction=ERROR_CORRECT_L,
box_size=10,
border=4
)
qr.add_data(data)
qr.make(fit=True)

# Generate the image with specified colors
img = qr.make_image(fill_color=fill_color, back_color=back_color)
img.save(file_path)
print(f"QR code saved as {file_path}")

img = qr.make_image(fill_color="black", back_color="white")
img.save("qrcode.png")
# Usage example
generate_qrcode("https://example.com", "my_qrcode.png")