mirror of https://github.com/zulip/zulip.git
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:
parent
92ba40b0c7
commit
13664f1289
|
@ -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()
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
|
@ -654,7 +654,8 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
|
|||
('img.png', 'png_resized.png'),
|
||||
('img.jpg', None), # jpeg resizing is platform-dependent
|
||||
('img.gif', 'gif_resized.png'),
|
||||
('img.tif', 'tif_resized.png')
|
||||
('img.tif', 'tif_resized.png'),
|
||||
('cmyk.jpg', None)
|
||||
]
|
||||
corrupt_files = ['text.txt', 'corrupt.png', 'corrupt.gif']
|
||||
|
||||
|
@ -821,7 +822,8 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
|
|||
('img.png', 'png_resized.png'),
|
||||
('img.jpg', None), # jpeg resizing is platform-dependent
|
||||
('img.gif', 'gif_resized.png'),
|
||||
('img.tif', 'tif_resized.png')
|
||||
('img.tif', 'tif_resized.png'),
|
||||
('cmyk.jpg', None)
|
||||
]
|
||||
corrupt_files = ['text.txt', 'corrupt.png', 'corrupt.gif']
|
||||
|
||||
|
|
Loading…
Reference in New Issue