phatch-dev team mailing list archive
-
phatch-dev team
-
Mailing list archive
-
Message #00001
Re: variable border action
On Thu, May 28, 2009 at 7:30 PM, Stani <spe.stani.be@xxxxxxxxx> wrote:
> Nadia, could you have a look at the palette/transparency part of the
> code? Just a second check.
>
Just in case my comments aren't clear in the referenced code:
In PIL.Image.Image._new, which is what actually provides the new image when
convert() is called, a type 'P' Image object will be assigned a new color
palette. This color palette has no relation to the color palette of the
actual image. (I consider this to be a very serious bug in PIL). So what I
do is get the palette from the converted image, and assign that to the
Image.palette.palette.
Secondly, since the color palette is most likely different after hte
conversion, a simple index will not work. Instead save the transparent color
value by looking up the index for it in the original palette. When the new
palette is assigned, I then search for the transparent color value and save
the appropriate index in the info['transparency'] attribute.
In my test cases this works fine. If I skip either step, this does not
work.
If there is a simpler way to do this, please let me know!
Regards,
Erich
Follow ups
References