List Info

Thread: Convert RGB to RGBA




Convert RGB to RGBA
user name
2006-08-18 17:27:08
Angelo wrote:

> Is it possible to convert a RGB image (png, tga or gif
image) to RGBA
> with PIL, and how to do that ? . With im.convert(mode,
matrix) ? .

the alpha layer controls transparency, and doesn't have any
direct 
relation to the RGB values.  to add an alpha layer to an
image, you can 
use a direct convert:

	imOut = im.convert("RGBA") # sets alpha to 255

if you have an RGB image, you can also modify it in place

	im.putalpha(value) # set alpha to given value

or

	im.putalpha(matte) # where matte is a mode "L"
image

</F>

_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )