plugin XEP-0264: Convert image to RGB if there is transparency:
JPEG doesn't support transparency, which was resulting in exception if a preview of an image with transparency was made. This is now checked, and the image is converted if necessary.
This commit is contained in:
parent
ebe072dbd4
commit
33f9554b94
1 changed files with 5 additions and 0 deletions
|
|
@ -167,6 +167,11 @@ class XEP_0264(object):
|
|||
with self.host.common_cache.cache_data(
|
||||
PLUGIN_INFO[C.PI_IMPORT_NAME], uid, MIME_TYPE, max_age
|
||||
) as f:
|
||||
# XXX: JPEG is used and doesn't support transparency, we need to convert
|
||||
# convert to RGB. We may want to change that in the future if another format
|
||||
# is used.
|
||||
if img.mode in ("RGBA", "LA", "P"):
|
||||
img = img.convert("RGB")
|
||||
img.save(f, SAVE_FORMAT)
|
||||
if fix_orientation:
|
||||
log.debug(f"fixed orientation for {f.name}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue