Skip to content

Commit

Permalink
Fixed deprecated Pillow API in examples. Closes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Oct 17, 2023
1 parent 9cf3fa2 commit 184c7ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/qrcode_text/png_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def qr_with_text(qrcode: segno.QRCode, *, text: str = None,
lines = text.splitlines()
# Calculate the additional space required for the text
for line in lines:
fw, fh = font.getsize(line)
try: # Pillow versions < 10
fw, fh = font.getsize(line)
except AttributeError:
fw, fh = font.getbbox(line)[2:4]
if fw > width:
width = fw + font_size
height += fh + line_spacing
Expand Down

0 comments on commit 184c7ec

Please sign in to comment.