Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved timings for gifs #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
for x in inventory["inventory"]:
sn_to_ip[ x["serial_number"] ] = x["ipv6_link_local"]

netInt="en10"
netInt="enp1s0"


# Tile images returns a 2d array of an input image split into tiles of given size.
Expand Down Expand Up @@ -125,16 +125,20 @@ def handle_gif(imageObject, duration=5):
while timetot < duration:
# Display individual frames from the loaded animated GIF file
for frame in range(0,imageObject.n_frames):
start_time = datetime.datetime.now()
imageObject.seek(frame)
sleep = imageObject.info['duration']/1000
sleep = sleep if sleep > 0 else 0.16
new_im = Image.new("RGB", imageObject.size)
new_im.paste(imageObject)
hl = tile_img(new_im, 18, crop=False) # False = scale.
send_images(hl)

timetot+= sleep
time.sleep(sleep)
timetot += sleep
end_time = datetime.datetime.now()
diff = end_time - start_time
actual_sleep = sleep - diff.total_seconds()
if actual_sleep > 0:
time.sleep(actual_sleep)



Expand Down