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

Fix: Pillow error when uploading RGBA image (#3325) #6241

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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