Skip to content

Exception when converting GIF to RGB and saving #2803

@tisdall

Description

@tisdall

I've reduced the issue down to 2 lines of code:

from PIL import Image
Image.open('plus.gif').convert('RGB').save('plus_thumb.gif', format='GIF')

The image with the issue:
plus

The exception I get:

# python test5.py 
/usr/local/lib/python2.7/site-packages/PIL/Image.py:967: UserWarning: Couldn't allocate palette entry for transparency
  "for transparency")
Traceback (most recent call last):
  File "test5.py", line 8, in <module>
    Image.open('plus.gif').convert('RGB').save('plus_thumb.gif', format='GIF')
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1928, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python2.7/site-packages/PIL/GifImagePlugin.py", line 465, in _save
    _write_single_frame(im, fp, palette)
  File "/usr/local/lib/python2.7/site-packages/PIL/GifImagePlugin.py", line 383, in _write_single_frame
    _write_local_header(fp, im, (0, 0), flags)
  File "/usr/local/lib/python2.7/site-packages/PIL/GifImagePlugin.py", line 490, in _write_local_header
    transparency = int(transparency)
TypeError: int() argument must be a string or a number, not 'tuple'

This is with Pillow 4.3.0 and Python 2.7.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.GIFPalette

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions