Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix: Pillow error when uploading RGBA image (#3325)
Browse files Browse the repository at this point in the history
Signed-Off-By: Filip Štědronský <g@regnarg.cz>
  • Loading branch information
regnarg committed Nov 19, 2019
1 parent 0467f33 commit 02c2680
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/6241.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error from the Pillow library when uploading RGBA images.
5 changes: 4 additions & 1 deletion synapse/rest/media/v1/thumbnailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,8 @@ def crop(self, width, height, output_type):

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

0 comments on commit 02c2680

Please sign in to comment.