[Image-SIG] PIL Convert Alpha-transparent image to non-transparent?

Bill Janssen janssen at parc.com
Tue Jul 6 01:35:12 CEST 2010


Chander Ganesan <chander.ganesan at gmail.com> 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


More information about the Image-SIG mailing list