Added SQL, dao and app - not functional
This commit is contained in:
19
functions/carteirinha.py
Normal file
19
functions/carteirinha.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import qrcode
|
||||
|
||||
def gerar_carteirinha(militante_id, nome):
|
||||
# Criar imagem base
|
||||
img = Image.new('RGB', (300, 200), color=(255, 255, 255))
|
||||
d = ImageDraw.Draw(img)
|
||||
|
||||
# Adicionar texto
|
||||
font = ImageFont.load_default()
|
||||
d.text((10, 10), f"Nome: {nome}", font=font, fill=(0, 0, 0))
|
||||
d.text((10, 30), f"ID: {militante_id}", font=font, fill=(0, 0, 0))
|
||||
|
||||
# Gerar QR code
|
||||
qr = qrcode.make(f"ID: {militante_id}")
|
||||
img.paste(qr, (200, 50))
|
||||
|
||||
# Salvar imagem
|
||||
img.save(f"carteirinha_{militante_id}.png")
|
||||
Reference in New Issue
Block a user