#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Posts
    2
    Rep Power
    0

    merge drawings N mask


    I'm writing a program that makes a png file by combining two other png files.

    It's joining them together but not quite the way I want it to. It joins drawing 'A'
    (which is a transparency) and places it on drawing 'B'. The end result is drawing 'C'
    which is not what I want. I want it to look like drawing 'D'.

    TechSmith | Screencast.com, online video sharing, Page not found

    The problem is this line

    image.paste(Image.open('bres sc4.png'), (int(300),int(400)))

    I think that I have to change this to something like what I have written below. Am I on the right track? Will you help me with this line

    image.paste(Image.open('bres sc4.png'), (int(300),int(400), mask='bres sc4.png')))
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,385
    Rep Power
    9645
    Want to try that link again? And have you tried that second line to see if it does what you want?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Posts
    2
    Rep Power
    0
    Sorry. How about now. Also, I tried that line

    TechSmith | Screencast.com, online video sharing, Page not found
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,385
    Rep Power
    9645
    Code:
    image.paste(Image.open('bres sc4.png'), (int(300),int(400), mask='bres sc4.png')))
    The third parameter is an Image, not a filename. Load the two images into variables then
    Code:
    D = B.paste(A, (300, 400), A)
    Note that .paste is only good if B does not have transparency. If it did then you would need to use something more complicated involving .alpha_composite.

IMN logo majestic logo threadwatch logo seochat tools logo