Skip to content

Commit

Permalink
Add nicer error message for frame['duration'] key error
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyNotChase committed Nov 18, 2020
1 parent 39db9bf commit cfc0077
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion glitch_this/glitch_this.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,15 @@ def glitch_gif(self, src_gif: Union[str, Image.Image], glitch_amount: Union[int,
* Save the glitched image in temp directory
* Open the image and append a copy of it to the list
"""
duration += frame.info['duration']
try:
duration += frame.info['duration']
except KeyError as e:
# Override error message to provide more info
e.args = (
'The key "duration" does not exist in frame.'
'This means PIL(pillow) could not extract necessary information from the input image',
)
raise
src_frame_path = os.path.join(self.gif_dirpath, 'frame.png')
frame.save(src_frame_path, compress_level=3)
if not i % step == 0:
Expand Down

0 comments on commit cfc0077

Please sign in to comment.