Skip to content

Commit

Permalink
Fix saving of non-RGB thumbnails as PNG (#17736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt authored Oct 8, 2024
1 parent b1b4b29 commit 60aebdb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/17736.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix saving of PNG thumbnails, when the original image is in the CMYK color space.
2 changes: 1 addition & 1 deletion synapse/media/thumbnailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def crop(self, width: int, height: int, output_type: str) -> BytesIO:
def _encode_image(self, output_image: Image.Image, output_type: str) -> BytesIO:
output_bytes_io = BytesIO()
fmt = self.FORMATS[output_type]
if fmt == "JPEG":
if fmt == "JPEG" or fmt == "PNG" and output_image.mode == "CMYK":
output_image = output_image.convert("RGB")
output_image.save(output_bytes_io, fmt, quality=80)
return output_bytes_io
Expand Down

0 comments on commit 60aebdb

Please sign in to comment.