add date to gif frames
This commit is contained in:
parent
1bc467ee69
commit
d41cdf41e9
@ -6,6 +6,8 @@ from collections import OrderedDict
|
||||
import imageio
|
||||
from progress.bar import IncrementalBar
|
||||
from pygifsicle import optimize
|
||||
from PIL import Image, ImageFont, ImageDraw, ImageFont
|
||||
import io
|
||||
|
||||
|
||||
def generate_map_timelapse(token_id, token_secret):
|
||||
@ -33,7 +35,19 @@ def generate_map_timelapse(token_id, token_secret):
|
||||
else:
|
||||
running_country_counts[country] = date_viewings_countries[country]
|
||||
|
||||
image = imageio.imread(FilmsByCountry.draw_map(running_country_counts, file_name="map-{}.svg".format(date)))
|
||||
map = FilmsByCountry.draw_map(running_country_counts, file_name="map-{}.svg".format(date))
|
||||
|
||||
stream = io.BytesIO(map)
|
||||
img = Image.open(stream)
|
||||
|
||||
map_editable = ImageDraw.Draw(img)
|
||||
map_editable.text((0, 0), "{}".format(date), (255, 64, 0))
|
||||
|
||||
img_byte_arr = io.BytesIO()
|
||||
img.save(img_byte_arr, format='PNG')
|
||||
img_byte_arr = img_byte_arr.getvalue()
|
||||
|
||||
image = imageio.imread(img_byte_arr)
|
||||
writer.append_data(image)
|
||||
|
||||
print("optimizing")
|
||||
|
Loading…
x
Reference in New Issue
Block a user