transparent images

half.italian at gmail.com half.italian at gmail.com
Tue May 15 20:38:31 EDT 2007


On May 15, 5:26 pm, moishyyeh... at gmail.com wrote:
> Does any one know how to make a transparent image with specifically
> PIL, but any standard python library will do. I need a spacer, and it
> has to be transparent.
>
> Thanks

Something like this...not my code...untested...

im = Image.open("image.jpg")
opacity = .5
if im.mode != 'RGBA':
    im = im.convert('RGBA')
else:
    im = im.copy()

alpha = im.split()[3]
alpha = ImageEnhance.Brightness(alpha).enhance(opacity)
im.putalpha(alpha)

~Sean




More information about the Python-list mailing list