Skip to content

Commit

Permalink
handle missing pillow more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Nov 22, 2024
1 parent ac7a860 commit 631a5b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xpra/codecs/icon_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ def load_icon_from_file(filename: str, max_size: int = MAX_ICON_SIZE) -> tuple:
return ()
log("load_icon_from_file(%s, %i)", filename, max_size)
if filename.endswith("xpm"):
from PIL import Image # pylint: disable=import-outside-toplevel
img = None
try:
from PIL import Image # pylint: disable=import-outside-toplevel
img = Image.open(filename)
buf = BytesIO()
img.save(buf, "PNG")
pngicondata = buf.getvalue()
buf.close()
return pngicondata, "png"
except ValueError as e:
except (ValueError, ImportError) as e:
log(f"Image.open({filename}) {e}", exc_info=True)
except Exception as e:
log(f"Image.open({filename})", exc_info=True)
Expand Down

0 comments on commit 631a5b2

Please sign in to comment.