PIL
Laszlo Zsolt Nagy
gandalf at geochemsource.com
Wed Mar 30 17:05:01 EST 2005
suresh mathi wrote:
>I use PIL for image manipulation.
>For drawing rectangles and other shapes PIL was really
>good.
>
>Now i am trying to paste 3 images into a single image.
>
>All 3 images that i try to paste are having a
>transparent background.
>When i try to open the image and paste the background
>becomes black. I masked the black areas but still the
>shape is not that clear.
>
>Is their any way to open the file in transparent mode
>or convert it into transparent mode.?
>
>
Try to convert your destination image with Image.mode("RGBA").
I had similar problems. The solution was to create an alpha channel
and merge the images using Image.composite. This was my code:
# Original image is "im"
# Remove transparency
white = Image.new("RGB",im.size,(255,255,255)) # Create new
white image
r,g,b,a = im.split()
im = Image.composite(im,white,a) # Create a composite
This is for removing transparency (make transparent areas white), but
probably you
can create an alpha channel for the new image being paster and make a
composite.
Best,
Laci
--
_________________________________________________________________
Laszlo Nagy web: http://designasign.biz
IT Consultant mail: gandalf at geochemsource.com
Python forever!
More information about the Python-list
mailing list