PIL - Transparency Nightmares

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tac-tics

    #1

    PIL - Transparency Nightmares

    I'm trying to make a simple script which attaches watermarks to every
    image in one directory and saves the output image to another. However,
    while I understand (in theory at least) what I need to be doing, I
    can't figure out where to go from here.

    First of all, I have a watermark image and a list of small images
    around 120px squared. The watermark uses alpha transparency, so the
    background is transparent and the anti-aliased text is partially
    transparent. For each image, I crop the watermark to the same size as
    the image. Now all I need to do is paste the watermark over the old
    image with respect to its transparency.

    I've tried Image.blend(), Image.composite (), and im.paste(), but none
    of them seem to do exactly what I want. What am I missing here?

  • tac-tics

    #2
    Re: PIL - Transparency Nightmares

    I RTFM harder, and found that paste with an image mask (using the
    watermark as the mask) does the trick.

    Comment

    Working...