[Image-SIG] Image.tostring method
Sat, 14 Oct 2000 17:25:53 +0200 (MET DST)
On Fri, 13 Oct 2000, Jeff Simpson wrote:
> I'm trying to use the Image.tostring method to spit out data for a gif
> image I have generated in a script. I can successfully use
> Image.save('blah.gif') to create a gif, but would like to be able to
> store this data in memory and eventually shove it into a web page - sans
> file. Does anyone have an example call (with args for the encoder).
> Here is what I've been using for Image.tostring:
> ....some steps to create the image with RGBA mode skipped
> # Now I wanna get the str data
> >>> data = im.tostring('gif', 'RGBA')
> >>> im.save(blah_a.gif')
> >>> fd = open('blah_b.gif', 'w')
> >>> fd.write(data)
> >>> fd.close()
> blah_a, generated from Image.save is happy and I can viedw it with xv.
> blah_b, generated with Image.tostring is bogus. I'm a little confused
> as to what needs to be passed to the encoder to make it work correctly.
works for me, perhaps "RGBA" with gif gives the troubles?
gif supports natively only 'P' or 'L'.