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

Signed-Off-By: Filip Štědronský <g@regnarg.cz>
This commit is contained in:
Filip Štědronský 2019-12-02 12:12:55 +00:00 committed by Richard van der Hoff
parent 23ea572125
commit 81731c6e75
2 changed files with 5 additions and 1 deletions

1
changelog.d/6241.bugfix Normal file
View File

@ -0,0 +1 @@
Fix error from the Pillow library when uploading RGBA images.

View File

@ -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