Does anybody know how to save an image in GIF format preserving transparent
background ??
Here's what I tested :
import Image, ImageDraw
im = Image.open('/path/to/model.gif') # An image with transparent backgroung
draw = ImageDraw.Draw(im)
draw.polygon([153,106,186,225,340,193,315,81,304,167], fill=9587)
im.save('/path/to/model1.gif', 'GIF')
And model1.gif has no transparent background anymore even if it's bigger
than my polygon selection.
Regards,
Laurent.
There was a patch published at one time that was supposed
to fix this. I remember doing some testing and not finding
it to work perfectly, but I may have been doing something
wrong. Can't recover it at the moment, but some search
engine work might turn it up.
--
Terry Hancock (han...@AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com
> There was a patch published at one time that was supposed
> to fix this. I remember doing some testing and not finding
> it to work perfectly, but I may have been doing something
> wrong. Can't recover it at the moment, but some search
> engine work might turn it up.
transparency write support was added in 2002.
however, PIL's Image object doesn't have a notion of "transparent
color index", so you have to keep track of it yourself.
im = Image.open(...)
transparency = im.info["transparency"]
...
out.save("out.gif", transparency=transparency)
</F>