use alpah compiste to merge due to tranparancy

This commit is contained in:
Fredrick W. Warren 2022-05-30 10:37:48 -07:00
parent b05cad5c56
commit 1f38c89b3a

View File

@ -10,7 +10,6 @@ def update_image(original, title, subtitle):
renders text on full sized slide renders text on full sized slide
make half sized copy for preview and fill top/bottom with white. make half sized copy for preview and fill top/bottom with white.
""" """
background = original
image = Image.new(mode="RGBA", size=(1280,720)) image = Image.new(mode="RGBA", size=(1280,720))
font1 = ImageFont.truetype('tahomabd.ttf', 50) font1 = ImageFont.truetype('tahomabd.ttf', 50)
font2 = ImageFont.truetype('tahomabd.ttf', 38) font2 = ImageFont.truetype('tahomabd.ttf', 38)
@ -19,7 +18,7 @@ def update_image(original, title, subtitle):
stroke_width=4, stroke_fill='black', spacing=4) stroke_width=4, stroke_fill='black', spacing=4)
draw.text((20,588), subtitle, font=font2, fill='white', draw.text((20,588), subtitle, font=font2, fill='white',
stroke_width=4, stroke_fill='black', spacing=4) stroke_width=4, stroke_fill='black', spacing=4)
background.paste(image, (0,0), image) background = Image.alpha_composite(original, image)
return background return background
def update_thumbnail(image): def update_thumbnail(image):