I'm trying to dynamically create a PNG (code is working) and make it transparent (code is not working on the color white).
I can create the PNG, but making it transparent isn't working.
Code:
from PIL import Image, ImageDraw, ImageFont
import os
def text_on_img(filename='01.png', text="Hello", size=12):
"Draw a text on an Image, saves it, show it"
fnt = ImageFont.truetype('arial.ttf', 52)
# create image
image = Image.new(mode="RGB", size=(150, 75), color="white")
draw = ImageDraw.Draw(image)
# draw text
draw.text((10, 10), text, font=fnt, fill=(0, 0, 0))
newData = []
newData.append((255, 255, 255, 0))
image.save(filename)