Skip to content

Commit

Permalink
Sometimes qrcode doesn't return a PILImage. In that case, save it wit…
Browse files Browse the repository at this point in the history
…hout format
  • Loading branch information
kennethjiang committed Apr 12, 2024
1 parent 4dc6d0c commit e83eb76
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/klipper_screen_obico_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ def update_qr_code(self, link_url):

img = qr.make_image(fill_color="black", back_color="white")
img_byte_arr = BytesIO()
img.save(img_byte_arr, format='PNG')
try:
img.save(img_byte_arr, format='PNG')
except Exception:
img.save(img_byte_arr) # Sometimes qrcode doesn't return a PILImage. In that case, save it without format

img_byte_arr = img_byte_arr.getvalue()

# Load the QR code image into a GdkPixbuf
Expand Down

0 comments on commit e83eb76

Please sign in to comment.