pil narysuj tekst w różnych kolorach

Cześć, aby narysować trzy różne teksty z różnymi opcjami na przykład:

text-number-1, font = arial, color = redtext-number-2, font = veranda, kolor = niebieski, rozmiar = 30text-number-3, font = tahoma, kolor = green, size = 40, align = center

tekst musi iść w nowych liniach.

def pil_image(request):
text = request.GET.get('text', None)
font = str(request.GET.get('font', 'arial'))
fontsize = int(request.GET.get('fontsize', '20'))
textcolor = str(request.GET.get('textcolor', '000'))

import Image, ImageDraw, ImageFont, textwrap

img = Image.open('media/text/transparent.png')
img = img.convert("RGBA")
datas = img.getdata()
w, h = img.size

newData = []
for item in datas:
    if item[0] == 255 and item[1] == 255 and item[2] == 255:
        newData.append((255, 255, 255, 0))
    else:
        newData.append(item)

img.putdata(newData)

draw = ImageDraw.Draw(img)
font = ImageFont.truetype("media/text/fonts/" + font + ".ttf", fontsize, encoding="unic")


margin = offset = 40
for line in textwrap.wrap(text, width=48):
    w, h = draw.textsize(line)
    draw.text((margin, offset), line, font=font, fill='#'+textcolor)
    offset += font.getsize(line)[1]

del draw 

img.save("media/text/custom.png", "PNG")

return HttpResponse("<img src='/media/text/custom.png'>");

questionAnswers(2)

yourAnswerToTheQuestion