![]() |
|
|
|
#1 |
|
Posts: n/a
|
Hi,
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. |
|
|
|
#2 |
|
Posts: n/a
|
It can only read transparency, it can't write it. I went looking and
found that out a couple weeks ago. |
|
|
|
#3 |
|
Posts: n/a
|
On 1 Feb 2006 14:41:05 -0800
"Kamilche" <> wrote: > It can only read transparency, it can't write it. I went > looking and found that out a couple weeks ago. 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 () Anansi Spaceworks http://www.AnansiSpaceworks.com |
|
|
|
#4 |
|
Posts: n/a
|
Terry Hancock wrote:
> 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> |
|