From 4b3174d7b236d46c8195f743fee170bf85dfc731 2017-09-03 14:00:18 From: Andrew Shadura Date: 2017-09-03 14:00:18 Subject: [PATCH] PYD-8: Fix generation of JPEG identicons with Pillow 4.2.0+: - Explicitly convert image to RGB before saving as JPEG. --- diff --git a/pydenticon/__init__.py b/pydenticon/__init__.py index 0edfdb02d25ee603310ffa465273550e746eda06..f499988266fc099ad9aa49ab50e8d259440d7dc8 100644 --- a/pydenticon/__init__.py +++ b/pydenticon/__init__.py @@ -246,6 +246,9 @@ class Generator(object): # Set-up a stream where image will be saved. stream = BytesIO() + if image_format.upper() == "JPEG": + image = image.convert(mode="RGB") + # Save the image to stream. try: image.save(stream, format=image_format, optimize=True)