image = '1.png'
watermark = '2.png'
wmark = Image.open(watermark)
img = Image.open(image)
ia, wa = None, None
if len(img.getbands()) == 4:
    ir, ig, ib, ia = img.split()
img = Image.merge('RGB', (ir, ig, ib))
if len(wmark.getbands()) == 4:
    wa = wmark.split()[-1]
img.paste(wmark, (0, 0), wmark)
if ia:
    if wa:
        ia = max_alpha(wa, ia)
img.putalpha(ia)
img.save('result.png')
PIL merge of two images with alpha channels - not working as expected