Changeset - 4b3174d7b236
[Not reviewed]
0 1 0
Andrew Shadura - 7 years ago 2017-09-03 14:00:18
andrew.shadura@collabora.co.uk
PYD-8: Fix generation of JPEG identicons with Pillow 4.2.0+:

- Explicitly convert image to RGB before saving as JPEG.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pydenticon/__init__.py
Show inline comments
 
@@ -243,12 +243,15 @@ class Generator(object):
 
                    # Draw the rectangle.
 
                    draw.rectangle((x1, y1, x2, y2), fill=foreground)
 

	
 
        # 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)
 
        except KeyError:
 
            raise ValueError("Pillow does not support requested image format: %s" % image_format)
 
        image_raw = stream.getvalue()
0 comments (0 inline, 0 general)