Overlay two same sized images in Python

Try using blend() instead of paste() – it seems paste() just replaces the original image with what you’re pasting in.

try:
    from PIL import Image
except ImportError:
    import Image

background = Image.open("bg.png")
overlay = Image.open("ol.jpg")

background = background.convert("RGBA")
overlay = overlay.convert("RGBA")

new_img = Image.blend(background, overlay, 0.5)
new_img.save("new.png","PNG")

Leave a Comment

tech