Skip to content

GIF images incorrectly converted to RGB #434

@cezarsa

Description

@cezarsa

After git bisecting the code I found that starting from commit b9ab3f5 there is a issue when converting GIFs from "P" format to either "RGB" or "RGBA".
In this case, pillow generates a black and white only image as it can be seen further down.
I'll try to understand what's happening and make a pull request latter.

This little snippet shows a way to reproduce it:

from PIL import Image
from urllib2 import urlopen
from io import BytesIO

imgbuffer = urlopen('http://www.eecs.berkeley.edu/~loarie/test.colors.gif').read()

img = Image.open(BytesIO(imgbuffer))
rgbimg = img.convert('RGB')
rgbimg.save(open('tmp.gif', 'w'), 'GIF')

Result:
tmp

Expected:
original

cc: commit author @d-schmidt

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions