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")
Answer from egor83 on Stack OverflowTry 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")
Maybe too old question, can be done with ease using opencv
cv2.addWeighted(img1, alpha, img2, beta, gamma)
#setting alpha=1, beta=1, gamma=0 gives direct overlay of two images
Documentation link
Overlaying Images over a baground image that I assigned
How to overlay two images with opacity
Image Overlay
Basic image overlay for multiple cameras (Python)
You don't need Numpy arrays at all for a simple overlay.
from PIL import Image
# Change to your file names, this is what mine downloaded as from your post
image_sem = Image.open('aZ8ED.jpg')
image_si = Image.open('HeiA7.jpg')
image_al = Image.open('HlcOR.jpg')
si_k = Image.blend(image_sem, image_si, 0.5)
si_k.show()
al_k = Image.blend(image_sem, image_al, 0.5)
al_k.show()
You'll have to crop or work with the picture label in the lower right corner for your needs and perhaps the color scale on the left, but this should get you started. It worked for me.

Edit based on OP comments:
The blend method outputs out = image1 * (1.0 - alpha) + image2 * alpha. To put all of them together, just successively combine the element images together, then blend that result with the master image as follows:
elements = Image.blend(image_si, image_al, 0.5)
elements_overlay = Image.blend(image_sem, elements, 0.5)
elements_overlay.show()

The blend method may not be the best for many images. The colors will fade, as the alpha makes the first element image a smaller weight of the final image as more element images are combined. See documentation for all means of combining images. For more complex combinations, you may want to use the Numpy array after all and do some normalization or tweaking of the actual pixels then recombine with fromarray or similar.
I would be inclined to paste Si and Al images using a mask so that they only affect the SEM image where they are coloured and not where they are black/grey - else you will tend to reduce the contrast of your base image:
from PIL import Image
# Load images
sei = Image.open('sei.jpg')
si = Image.open('si.jpg')
al = Image.open('al.jpg')
# Make mask which only allows coloured areas to show
siMask = si.convert('L')
siMask.save('DEBUG-siMask.jpg')
# Paste Si image over SEM image with transparency mask
sei.paste(si, siMask)
# Make mask which only allows coloured areas to show
alMask = al.convert('L')
alMask.save('DEBUG-alMask.jpg')
# Paste Al image over SEM image with transparency mask
sei.paste(al, alMask)
sei.save('result.png')
DEBUG-siMask.jpg

DEBUG-alMask.jpg

result.jpg

Note that you could enhance the masks before use - for example you could median filter to remove small speckles, or you could contrast stretch to make the magenta/yellow shading come out more or less solid. For example, you can see the yellow is more solid than the magenta, which is because the yellow mask is brighter, so you could threshold the magenta mask to make it pure black and white which would make the magenta come out solid.
So, I median-filtered out the speckles and changed the masking so that coloured areas are 50% transparent like this:
#!/usr/bin/env python3
from PIL import Image, ImageFilter
# Load images
sei = Image.open('sei.jpg')
si = Image.open('si.jpg')
al = Image.open('al.jpg')
# Make mask which only allows coloured areas to show
siMask = si.convert('L')
# Median filter mask to remove small speckles
siMask = siMask.filter(ImageFilter.MedianFilter(5))
# Threshold mask and set opacity to 50% for coloured areas
siMask = siMask.point(lambda p: 128 if p > 50 else 0)
siMask.save('DEBUG-siMask.jpg')
# Paste Si image over SEM image with transparency mask
sei.paste(si, siMask)
# Make mask which only allows coloured areas to show
alMask = al.convert('L')
# Median filter mask to remove small speckles
alMask = alMask.filter(ImageFilter.MedianFilter(5))
# Threshold mask and set opacity to 50% for coloured areas
alMask = alMask.point(lambda p: 128 if p > 50 else 0)
alMask.save('DEBUG-alMask.jpg')
# Paste Al image over SEM image with transparency mask
sei.paste(al, alMask)
sei.save('result.jpg')
That gives these masks and results:



Hello everyone, I need some help to automate picture editing for my bussines, I was wondering if someone here could help me make a code to automate this task. I usually download some pictures that are free of copyright and then jump into canva to add the information of my bussines, but it takes too long to do it for each photo.
I have tryied using the "Pillow" package and also "cv2" but hasnt work for me, I always get an error. So if any of you guys could help me with the code, I'll really apreciate that.