Skip to content

Commit 017fd96

Browse files
committed
Fix bug with single looped animation
1 parent e56afe2 commit 017fd96

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

examples/is31fl3731_pillow_animated_gif.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
2525
display = adafruit_is31fl3731.CharlieBonnet(i2c)
2626

27-
# Check that the gif was specified
27+
# Open the gif
2828
if len(sys.argv) < 2:
2929
print("No image file specified")
3030
print("Usage: python3 is31fl3731_pillow_animated_gif.py animated.gif")
3131
sys.exit()
3232

33-
# Open the gif
3433
image = Image.open(sys.argv[1])
3534

3635
# Make sure it's animated
@@ -40,11 +39,14 @@
4039

4140
# Get the autoplay information from the gif
4241
delay = image.info['duration']
43-
loops = image.info['loop']
4442

45-
# Adjust loop count (0 is forever)
46-
if loops > 0:
47-
loops += 1
43+
# Figure out the correct loop count
44+
if "loop" in image.info:
45+
loops = image.info['loop']
46+
if loops > 0:
47+
loops += 1
48+
else:
49+
loops = 1
4850

4951
# IS31FL3731 only supports 0-7
5052
if loops > 7:

0 commit comments

Comments
 (0)