File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 24
24
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
25
25
display = adafruit_is31fl3731 .CharlieBonnet (i2c )
26
26
27
- # Check that the gif was specified
27
+ # Open the gif
28
28
if len (sys .argv ) < 2 :
29
29
print ("No image file specified" )
30
30
print ("Usage: python3 is31fl3731_pillow_animated_gif.py animated.gif" )
31
31
sys .exit ()
32
32
33
- # Open the gif
34
33
image = Image .open (sys .argv [1 ])
35
34
36
35
# Make sure it's animated
40
39
41
40
# Get the autoplay information from the gif
42
41
delay = image .info ['duration' ]
43
- loops = image .info ['loop' ]
44
42
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
48
50
49
51
# IS31FL3731 only supports 0-7
50
52
if loops > 7 :
You can’t perform that action at this time.
0 commit comments