0

I am writing a program to create some Cards for my own "Cards against humanity". here is my code:

from PIL import Image, ImageDraw, ImageFont
import re

arialbold = ImageFont.truetype("arialbd.ttf",size=100)

while(True):

    testimg = Image.open("white.png")

    intext = input() + " "
    if(intext == " "):
        break

    inlist = list(intext)
    pattern = " "
    su = 0
    last = 0
    lastlen = 0

    for match in re.finditer(pattern,intext):
        su = su + (match.start() - last)
        print(su)
        if(su > 12):
            inlist[last] = '\n'
            su = lastlen
        lastlen = (match.start() - last)
        last = match.start()

    out = ''.join(inlist)

    tempimg = ImageDraw.Draw(testimg)
    tempimg.text((100,100),out ,fill= "#000000", font=arialbold)

    nameOfSave = re.sub('\W' ,'',intext[0:30])

    testimg.save(nameOfSave + ".png")

What I want to do is to just add a black ext (or later a white Text on black background) to the card, without changing any colors exept the text color.

But my output images are constantly blue and I do not understand why. this is white.png this is the output picture

I tried to change fill= 255 fill= (255,255,255) but it didn't help

thanks for any help in advance!

eli44
  • 111
  • 1
  • 12

1 Answers1

0

testimg = Image.open("white.png").convert('RGB') helped and did the thing!

thanks to Mark Setchell

I am still curious, why it changed to blue though..

eli44
  • 111
  • 1
  • 12