uploads: Convert CMYK to RGB when saving avatar/realm icon as png.

Fixes #8546.
PNG does not support CMYK mode. CMYK file is converted to RGB and
then saved as PNG.
This commit is contained in:
Shubham Padia
2018-03-02 22:26:25 +05:30
committed by Tim Abbott
parent 92ba40b0c7
commit 13664f1289
3 changed files with 6 additions and 2 deletions

View File

@@ -88,6 +88,8 @@ def resize_avatar(image_data: bytes, size: int=DEFAULT_AVATAR_SIZE) -> bytes:
except IOError:
raise BadImageError("Could not decode image; did you upload an image file?")
out = io.BytesIO()
if im.mode == 'CMYK':
im = im.convert('RGB')
im.save(out, format='png')
return out.getvalue()