From 33f9554b94ac04262700c5fa1ab63fc9760126f8 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 4 Jul 2026 10:44:29 +0200 Subject: [PATCH] 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. --- libervia/backend/plugins/plugin_xep_0264.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libervia/backend/plugins/plugin_xep_0264.py b/libervia/backend/plugins/plugin_xep_0264.py index 284f11df..78bfe5a7 100644 --- a/libervia/backend/plugins/plugin_xep_0264.py +++ b/libervia/backend/plugins/plugin_xep_0264.py @@ -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}")