Re: PIL Convert Alpha-transparent image to non-transparent?

Bill Janssen <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
Chander Ganesan <[email protected]> wrote:

> - Iterate over the pixels and find those that are more than 50%
> transparent and convert them to white (ends up with a dithered image)
> - Use Paste onto a white background that has no transparency, and then
> convert to RGB (no luck there)
> - Use Image.blend to attempt to blend with a white background (at
> various levels), no luck there.

You're close.  You want to use Image.paste onto that white background, but
using the same image you're pasting as the optional third mask argument
for the paste:

  background.paste(rgba_image, (0, 0), rgba_image)

"rgba_image" must be the same size as "background".

Bill
_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.