Thumbnail: Fix CMYK images

This commit is contained in:
Raphael Michel
2018-03-21 09:55:38 +01:00
parent 1ef3f83e46
commit 5cbcbe6d7e

View File

@@ -58,6 +58,8 @@ def create_thumbnail(sourcename, size):
checksum = hashlib.md5(image.tobytes()).hexdigest() checksum = hashlib.md5(image.tobytes()).hexdigest()
name = checksum + '.' + size.replace('^', 'c') + '.png' name = checksum + '.' + size.replace('^', 'c') + '.png'
buffer = BytesIO() buffer = BytesIO()
if image.mode not in ("1", "L", "RGB"):
image = image.convert('RGB')
image.save(fp=buffer, format='PNG') image.save(fp=buffer, format='PNG')
imgfile = ContentFile(buffer.getvalue()) imgfile = ContentFile(buffer.getvalue())