summary refs log tree commit diff
diff options
context:
space:
mode:
authorFilip Štědronský <p@regnarg.cz>2019-12-02 12:12:55 +0000
committerRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-12-02 12:12:55 +0000
commit81731c6e75fe904a5b44873efa361a229743d99f (patch)
tree32ed2e862adcf0f2ff8acebb806a6d860c4cc034
parentAdd User-Interactive Auth to /account/3pid/add (#6119) (diff)
downloadsynapse-81731c6e75fe904a5b44873efa361a229743d99f.tar.xz
Fix: Pillow error when uploading RGBA image (#3325) (#6241)
Signed-Off-By: Filip Štědronský <g@regnarg.cz>
-rw-r--r--changelog.d/6241.bugfix1
-rw-r--r--synapse/rest/media/v1/thumbnailer.py5
2 files changed, 5 insertions, 1 deletions
diff --git a/changelog.d/6241.bugfix b/changelog.d/6241.bugfix
new file mode 100644
index 0000000000..25109ca4a6
--- /dev/null
+++ b/changelog.d/6241.bugfix
@@ -0,0 +1 @@
+Fix error from the Pillow library when uploading RGBA images.
diff --git a/synapse/rest/media/v1/thumbnailer.py b/synapse/rest/media/v1/thumbnailer.py
index 8cf415e29d..c234ea7421 100644
--- a/synapse/rest/media/v1/thumbnailer.py
+++ b/synapse/rest/media/v1/thumbnailer.py
@@ -129,5 +129,8 @@ class Thumbnailer(object):
 
     def _encode_image(self, output_image, output_type):
         output_bytes_io = BytesIO()
-        output_image.save(output_bytes_io, self.FORMATS[output_type], quality=80)
+        fmt = self.FORMATS[output_type]
+        if fmt == "JPEG":
+            output_image = output_image.convert("RGB")
+        output_image.save(output_bytes_io, fmt, quality=80)
         return output_bytes_io