Badge Creator for Course

You'll need:

1. A Badge template (Model)

2. List of people (Example)

3. A small python program

4. Optional: QR Code Reader (Example: http://qrcode.kaywa.com/)

Python Program

import Image, ImageFont, ImageDraw
from pygooglechart import QRChart

fontfile = r"C:\WINDOWS\Fonts\arialbd.ttf"
xsize = 626
ysize = 1004
QRx = 177*2
QRy = 177*2
plan = [i.split(',') for i in open('fscurso.csv').readlines()]
plan = plan[1:]

for i in plan:
    words = [
        ((140, 830+60), i[2].decode("Latin-1"), "#B05D30", 45),
        ((140, 890+60), i[6], "#0000ff", 30),
        ]

    im = Image.open("model.png")
    dr = ImageDraw.Draw(im)

    for pos, text, color, size in words:
        font = ImageFont.truetype(fontfile, size)
        textSize = font.getsize(text)
        centerLocation = ((xsize - textSize[0]) / 2,pos[1])
        dr.text(centerLocation, text, font=font, fill=color)
    font2 = ImageFont.truetype(fontfile, 15)        
    dr.text (((xsize)/2-180,(ysize+QRy)/2-70),"Read from your mobile: http://reader.kaywa.com",font=font2, fill="#000000")

    chart = QRChart(QRx, QRy)
    vCard = "BEGIN:VCARD\nVERSION:2.1\nN:%s\nORG:%s\nTEL;WORK;VOICE:%s\nEMAIL;PREF;INTERNET:%s\nREV:20090309T105243Z\nEND:VCARD"%(i[2],i[6],i[7],i[4])
    chart.add_data(vCard)
    chart.set_ec('H', 0)
    chart.download('qr-hello.png')
    im2 = Image.open('qr-hello.png')
    im.paste(im2,((xsize-QRx)/2,(ysize-QRy)/2-80,(xsize+QRx)/2,(ysize+QRy)/2-80))
    im.save("cracha\\%s.jpg"%i[2],dpi=(300,300))

BadgeCreator (last edited 2009-03-24 17:12:13 by PedroOliveira)