[Image-SIG] (no subject)

charlie clark charlie at begeistert.org
Fri Apr 22 16:31:41 CEST 2005

"charlie clark" wrote:

> I would like to be able to mark areas on a map with round points. I 
> already have the round points as a separate graphic with a transparent 
> background. When I use Image.paste(im, (10, 10)) the paste works but the 
> background of the pasted image is white rather than transparent. I think 
> that I should be doing something with a mask but I don't quite 
> understand how this works. Thanks for any tips.

> to do a transparent paste, you need to pass in the mask (or matte) as the
> third argument.

> if you're pasting RGBA data into an RGB image, you can simply pass in the
> overlay itself as the third argument:

     image.paste(im, (10, 10), im)

Yes, I've tried this but it didn't make any difference.

> if you're using P images, you have to create a mask first.  something 
> like this
> might work:

     lut = [1] * 256
     lut[im.info["transparency"]] = 0

     mask = im.point(lut, "1")
     image.paste(im, (10, 10), mask)

Yes, it would when I understood it better! :-/

I'm working with .GIFs which as I understand it are P (palette) images. I 
had hoped that using convert("RGBA") would map the transparency to the 
alpha channel. But it didn't. I need to use RGB as otherwise the palettes 
of both images get mixed up.

I tried your example but got "images don't match" because I'd converted to 
RGBA abd im.point is expecting a Palette. Reloading and not converting the 
image and everything works fine. But I can't admit to understanding 

Trying to understand things: lut is effectively a palette table all set to 
the same value?
What does lut[im.info["transparency"]] = 0 do?
In my case its would sets lut[14] = 0
So the real magic is im.point() which creates a single band presumably 
reacting to the transparency in the original image.

Sorry for the really simple questions but even though I've now got this 
working, I like to understand how!



More information about the Image-SIG mailing list