26 lines
868 B
Python
Raw Normal View History

2022-02-05 13:00:32 +01:00
import PIL.Image, PIL.ImageDraw, PIL.ImageFont
import os
import sys
font = PIL.ImageFont.truetype(os.path.join(os.path.dirname(__file__), 'IBMPlexMono.ttf'), 20)
nFrames = 60
width = 500
height = 500
if __name__ == "__main__":
tpe = sys.argv[1]
username = sys.argv[2]
description = sys.argv[3]
target = sys.argv[4]
animated_gif = Image.open("./customAlertsMedia/"+tpe+".gif")
frames = []
for frame in ImageSequence.Iterator(animated_gif):
frame = frame.convert('RGB')
d = PIL.ImageDraw.Draw(frame)
d.text((0, 0), description, font=font, fill=(255, 255, 255))
d.text((0, 100), username, font=font, fill=(255, 255, 255))
frames.append(frame)
frames[0].save(target+tpe+".gif", save_all=True, append_images=frames[1:], duration=100, loop=0, optimize=0, comment="")
os.popen('cp ./customAlertsMedia/'+tpe+'.mp3 '+target+tpe+'.mp3')