Commit 3c704f95 authored by Thilo Molitor's avatar Thilo Molitor

Added ability to display avatars in all image formats that are supported by...

Added ability to display avatars in all image formats that are supported by pillow (if pillow is available)
parent bc4a4a06
......@@ -37,6 +37,11 @@ from gi.repository import Pango
import os
import sys
import importlib
try:
from PIL import Image
except:
pass
from io import BytesIO
import logging
log = logging.getLogger('gajim.gtkgui_helpers')
......@@ -418,6 +423,16 @@ def get_pixbuf_from_data(file_data, want_type = False):
returns 'jpeg', 'png' etc
"""
pixbufloader = GdkPixbuf.PixbufLoader()
# try to open and convert every image format supported by PILLOW to png format
try:
avatar = Image.open(BytesIO(file_data)).convert("RGB")
output = BytesIO()
avatar.save(output, format='PNG')
file_data = output.getvalue()
output.close()
except:
log.debug("Could not use pillow to convert avatar image (this is non fatal)")
pass # this didn't work, so just use the old gtk code to import the image
try:
pixbufloader.write(file_data)
pixbufloader.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment