Now, we go to the final result with text, lines and images all in the same output
import os
from PIL import Image, ImageDraw, ImageFont
filename='a.png'
ironman = Image.open(filename, 'r')
filename1='bg.jpg'
bg = Image.open(filename1, 'r')
text_img = Image.new('RGBA', (600,320), (0, 0, 0, 0))
text_img.paste(bg, (0,0))
text_img.paste(ironman, (0,0), mask=ironman)
# text_img.save("ball.png", format="png")
draw = ImageDraw.Draw(text_img)
draw.text((150,80),"Hello everybody!")
draw.line((160,100,250,100))
draw.line((200,100,190,110))
text_img
Out[96]:
Comments
Post a Comment