Skip to content

Commit

Permalink
Fix #4
Browse files Browse the repository at this point in the history
Don't generate 0-width or 0-height images
  • Loading branch information
waveform80 committed Aug 6, 2018
1 parent 123ad6e commit 083fe6a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pisense/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def draw_text(text, font='default.pil', size=8, foreground=Color('white'),
width, height = draw.textsize(text, f, spacing=1)
pad_left, pad_top, pad_right, pad_bottom = padding
pad_top = max(pad_top, min_height - (pad_top + height + pad_bottom))
if pad_left + width + pad_right == 0 or pad_top + height + pad_bottom == 0:
raise ValueError('Cannot generate an image with 0 width or height')
img = Image.new('RGB', (
pad_left + width + pad_right,
pad_top + height + pad_bottom
Expand Down

0 comments on commit 083fe6a

Please sign in to comment.