Skip to content

Commit

Permalink
#3275 don't fail opengl if pillow lacks jpeg support
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Sep 21, 2021
1 parent fdfe886 commit b8db039
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions xpra/client/gl/window_backend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# This file is part of Xpra.
# Copyright (C) 2018, 2019 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2018-2021 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -10,7 +10,7 @@
from math import cos, sin

from xpra.util import typedict, envint, AdHocStruct, AtomicInteger, iround
from xpra.os_util import WIN32
from xpra.os_util import WIN32, load_binary_file
from xpra.log import Logger
from xpra.platform.paths import get_icon_filename

Expand Down Expand Up @@ -140,10 +140,16 @@ def paint_callback(success, message=""):
noalpha = Image.new("RGB", img.size, (255, 255, 255))
noalpha.paste(img, mask=img.split()[3]) # 3 is the alpha channel
buf = BytesIO()
noalpha.save(buf, format="JPEG")
icon_data = buf.getvalue()
buf.close()
icon_format = "jpeg"
try:
noalpha.save(buf, format="JPEG")
icon_data = buf.getvalue()
buf.close()
icon_format = "jpeg"
except KeyError as e:
log("save()", exc_info=True)
log.warn("OpenGL using png as jpeg is not supported by Pillow: %s", e)
icon_data = load_binary_file(gl_icon)
icon_format = "png"
if not icon_data:
icon_w = 32
icon_h = 32
Expand Down

0 comments on commit b8db039

Please sign in to comment.