adding the logic to generate the image

This commit is contained in:
2026-03-14 02:50:54 -04:00
parent 6b651d3c4f
commit 21533ff4f5
14 changed files with 188 additions and 56 deletions

View File

@@ -0,0 +1,19 @@
from io import BytesIO
import qrcode
def generate_qr_image_bytes(text: str, size: int = 300) -> bytes:
img = qrcode.make(text)
# Ensure RGB for consistent PNG output
if getattr(img, "mode", None) != "RGB":
img = img.convert("RGB")
if size:
img = img.resize((size, size))
buf = BytesIO()
img.save(buf, "PNG")
buf.seek(0)
return buf.getvalue()