from PIL import Image, ImageDraw, ImageSequence, ImageFont import io import click FIRST_NUMBER = click.prompt('Enter the low number of the range', default=10330, type=int) LAST_NUMBER = click.prompt('Enter the high number of the range', default=10346, type=int) FRAME_DURATION = click.prompt('How long to hold on each number', default=100, type=int) ANIMATED_GIF_FILENAME = click.prompt('Enter the name of the animated gif to generate', default="incrementing-counter.gif", type=str) TEXT_COLOR = (255,255,255) TEXT_SIZE = (5,-2) TEXT_BG_COLOR = (0,0,0) TEXT_BG_SIZE = (115,40) # Download: https://github.com/blaisck/sfwin/blob/master/SFPro/TrueType/SFProDisplay-Regular.ttf fnt = ImageFont.truetype("SFProDisplay-Regular.ttf", 36) frames = [] for count in list(range(FIRST_NUMBER, LAST_NUMBER)): new_img = Image.new('RGB', TEXT_BG_SIZE, TEXT_BG_COLOR) draw = ImageDraw.Draw(new_img) draw.text(TEXT_SIZE, str(count), font = fnt, fill=TEXT_COLOR) frames.append(new_img) frames[0].save(ANIMATED_GIF_FILENAME, format='GIF', append_images=frames[1:], save_all=True, duration=FRAME_DURATION, loop=0) print(f'Generated animated gif at ./{ANIMATED_GIF_FILENAME}')