Create an easy to read QR code and URL shortener
Generate easy-to-read QR codes in PNG or SVG format, optionally specifying the linked URL, transparency, and pixel size.
import requests
url_to_encode = "https://example.com"
pixel_size = 4 # Optional: pixel size (default is 1)
output_format = "png" # "png" or "svg"
is_transparent = False # Set to True for transparent background
base_url = "https://qrtag.net/api/qr"
if is_transparent:
base_url += "_transparent"
if pixel_size:
base_url += f"_{pixel_size}"
api_url = f"{base_url}.{output_format}?url={requests.utils.quote(url_to_encode)}"
response = requests.get(api_url)
if response.status_code == 200:
# Save the QR code image
with open(f"qr_code.{output_format}", "wb") as f:
f.write(response.content)
print(f"QR code saved to qr_code.{output_format}")
else:
print(f"Failed to generate QR code: {response.status_code}")Last 50 checks (10 min intervals)