[Image-SIG] Re: GIF problems

David Ascher da@skivs.ski.org
Thu, 10 Dec 1998 10:14:52 -0800 (Pacific Standard Time)

On Thu, 10 Dec 1998, Fredrik Lundh wrote:

> if you want an entire GIF file, the right way
> to do it is:
>     fp = StringIO.StringIO()
>     i.save(fp, "GIF")

That line produces the same error:

    i.save(fp, "GIF")
  File "c:\Extras\PIL\Image.py", line 551, in save
    SAVE[string.upper(format)](self, fp, filename)
  File "c:\Extras\PIL\GifImagePlugin.py", line 229, in _save
    ImageFile._save(im, fp, [("gif", (0,0)+im.size, 0, RAWMODE[im.mode])])
  File "c:\Extras\PIL\ImageFile.py", line 209, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "c:\Extras\PIL\Image.py", line 174, in _getencoder
    return apply(encoder, args + extra)
TypeError: illegal argument type for built-in operation

>     data = fp.getvalue()
> but assuming you already knew that, and really
> want to run the gif encoder (which produces
> uncompressed LWZ data, but no headers), you
> could try something like:
>     data = i.tostring("gif", i.mode)

same here.