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 Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › overlay-an-image-on-another-image-in-python
Overlay an image on another image in Python - GeeksforGeeks
July 23, 2025 - Firstly we opened the primary image and saved its image object into variable img1. Then we opened the image that would be used as an overlay and saved its image object into variable img2. Then we called the paste method to overlay/paste the passed image on img1.
Discussions

Overlaying Images over a baground image that I assigned
Hi fellow developers I want to overlay a image over the baground that I assigned in Tkinter is there a way to do it? More on discuss.python.org
🌐 discuss.python.org
1
0
May 22, 2022
How to overlay two images with opacity
I have a simple problem, I want to overlay two rgb images (np.arrays with three channels and same size) over each other, with opacity setting for the top so I can see both. fig_visual_check = go.Figure() fig_visual_chec… More on community.plotly.com
🌐 community.plotly.com
10
0
June 7, 2023
Image Overlay
I watched a video that explains how to put in some watermarks but the thing is the watermarks are just text, can't put another photo and in my case im using my logo and another logo in the right down corner, and also making the photo a bit transparent for the text to be more visible. I didnt got an error there with the watermarks but wanted to see if anybody knows the script for adding a photo like an overlay to the original photo and also make it a bit transparent, or if someone knows a video that explains it so I can replicate that. I have little to no knowledge of programing but I think this would be a very nice tool to have for quick posting and making publicity and everybody that needs to make publicity of their bussines should use for saving a lot of time, so if any content creator reads this post, it would be a great proyect and there are no videos on youtube. More on reddit.com
🌐 r/PythonLearning
6
3
October 21, 2024
Basic image overlay for multiple cameras (Python)
Think it should be doable using ffmpeg. Can resize and place multiple sources of content, can easily overlay stuff, can probably work with multiple video streams, etc. You'd then switch video stream in your video player (VLC let's you do that) More on reddit.com
🌐 r/programmingrequests
1
1
June 21, 2024
Top answer
1 of 2
4

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.

2 of 2
2

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:

🌐
Python.org
discuss.python.org › python help
Overlaying Images over a baground image that I assigned - Python Help - Discussions on Python.org
May 22, 2022 - Hi fellow developers I want to overlay a image over the baground that I assigned in Tkinter is there a way to do it?
🌐
GitHub
github.com › pydemo › overlay
GitHub - pydemo/overlay: Overlay 2 images using python and OpenCV · GitHub
#OVERLAY OPACITY = 0.7 added_image = cv2.addWeighted(new_background,0.6,square,0.4,0) cv2.imshow('adjusted', added_image) cv2.waitKey() cv2.imwrite(out, added_image)
Author: pydemo
🌐
Moonbooks
moonbooks.org › Articles › How-to-overlay--superimpose-two-images-using-python-and-pillow-
How to overlay / superimpose two images using python and pillow ?
August 24, 2022 - from PIL import Image import numpy as np img = Image.open("data_mask_1354_2030.png") background = Image.open("background_1354_2030.png") background.paste(img, (0, 0), img) background.save('how_to_superimpose_two_images_01.png',"PNG")
🌐
Plotly
community.plotly.com › 📊 plotly python
How to overlay two images with opacity - 📊 Plotly Python - Plotly Community Forum
June 7, 2023 - I have a simple problem, I want to overlay two rgb images (np.arrays with three channels and same size) over each other, with opacity setting for the top so I can see both. fig_visual_check = go.Figure() fig_visual_check = fig_visual_check.add_trace(go.Image(z=images_merged_visual[0], opacity=0.5)) fig_visual_check = fig_visual_check.add_trace(go.Image(z=images_merged_visual[1], opacity=1)) fig_visual_check However, the result is just a black image.
Find elsewhere
🌐
Quora
quora.com › How-can-I-overlay-2-images-of-different-sizes-using-Python
How to overlay 2 images of different sizes using Python - Quora
Answer (1 of 2): overlay of 2 images of different sizes I posted details on github: pydemo/overlay Background image Foreground image Get images width/height [code]b_h, b_w, b_ch = background.shape o_h, o_w, o_ch = overlay.shape [/code]Scale background image [code] W = 800 imgScale =...
🌐
PyImageSearch
pyimagesearch.com › home › blog › transparent overlays with opencv
Transparent overlays with OpenCV - PyImageSearch
April 17, 2021 - This tutorial demonstrates how to use OpenCV to create transparent overlays with the cv2.addWeighted function and OpenCV + Python bindings.
🌐
Python Examples
pythonexamples.org › pillow-image-overlay
Image Overlaying in Python with Pillow
To overlay an image over a base image in Python with Pillow library, you can use Image.paste() method. In this tutorial, you will learn how to use Image.paste() to over an image over another with examples.
🌐
Medium
medium.com › @alexppppp › adding-objects-to-image-in-python-133f165b9a01
Adding Objects to Image in Python | Medium
February 3, 2022 - Guide on how to overlay a small image over a big image using Python, OpenCV and Numpy
🌐
Reddit
reddit.com › r/pythonlearning › image overlay
r/PythonLearning on Reddit: Image Overlay
October 21, 2024 -

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.

Top answer
1 of 2
1
I watched a video that explains how to put in some watermarks but the thing is the watermarks are just text, can't put another photo and in my case im using my logo and another logo in the right down corner, and also making the photo a bit transparent for the text to be more visible. I didnt got an error there with the watermarks but wanted to see if anybody knows the script for adding a photo like an overlay to the original photo and also make it a bit transparent, or if someone knows a video that explains it so I can replicate that. I have little to no knowledge of programing but I think this would be a very nice tool to have for quick posting and making publicity and everybody that needs to make publicity of their bussines should use for saving a lot of time, so if any content creator reads this post, it would be a great proyect and there are no videos on youtube.
2 of 2
1
Pillow is the right tool. What kind of error messages are you getting? I imagine you have all of these images saved to a folder. The general structure of the program would be first reading the contents of that folder to get all the image file names stored as a list. Then you would create a for loop--for image in list: do the following... Create an PIL image object with the picture then add text to it with location coordinates and save that modified image to a new folder location with a new name. Then repeat for the next image in the list. Is that how you have structured your script? How far have you gotten?
🌐
Folium
python-visualization.github.io › folium › latest › user_guide › raster_layers › image_overlay.html
ImageOverlay — Folium 1.0.0rc1 documentation
Now, let’s try to add a line at latitude 45°, and add a polyline to verify it’s well rendered. We’ll need to specify origin='lower to inform folium that the first lines of the array are to be plotted at the bottom of the image (see numpy.imshow, it’s the same principle).
🌐
GeeksforGeeks
geeksforgeeks.org › python › transparent-overlays-with-python-opencv
Transparent overlays with Python OpenCV - GeeksforGeeks
July 23, 2025 - import cv2 import numpy as np # Loading our images # Background/Input image background = cv2.imread('Assets/img1.jpg') # Overlay image overlay_image = cv2.imread('Assets/overlay3.png') # Resize the overlay image to match the bg image dimensions overlay_image = cv2.resize(overlay_image, (1000, 1000)) h, w = overlay_image.shape[:2] # Create a new np array shapes = np.zeros_like(background, np.uint8) # Put the overlay at the bottom-right corner shapes[background.shape[0]-h:, background.shape[1]-w:] = overlay_image # Change this into bool to use it as mask mask = shapes.astype(bool) # We'll create
🌐
GitConnected
levelup.gitconnected.com › how-to-approach-image-overlay-problems-ad2d4a8e22bc
How to approach image overlay problems | by Shaurya Agarwal | Level Up Coding
December 14, 2021 - For Python OpenCV can be downloaded using pip install opencv-python. Any image can be read in opencv using cv2.imread() command.
🌐
Python
wiki.python.org › moin › PyQt › Painting an overlay on an image
PyQt/Painting an overlay on an image
1 import sys 2 from PyQt4.QtCore import * 3 from PyQt4.QtGui import * 4 5 if __name__ == "__main__": 6 7 app = QApplication(sys.argv) 8 9 if len(app.arguments()) < 2: 10 11 sys.stderr.write("Usage: %s <image file> <overlay file>\n" % sys.argv[0]) 12 sys.exit(1) 13 14 image = QImage(app.arguments()[1]) 15 if image.isNull(): 16 sys.stderr.write("Failed to read image: %s\n" % app.arguments()[1]) 17 sys.exit(1) 18 19 overlay = QImage(app.arguments()[2]) 20 if overlay.isNull(): 21 sys.stderr.write("Failed to read image: %s\n" % app.arguments()[2]) 22 sys.exit(1) 23 24 if overlay.size() > image.size(): 25 26 overlay = overlay.scaled(image.size(), Qt.KeepAspectRatio) 27 28 painter = QPainter() 29 painter.begin(image) 30 painter.drawImage(0, 0, overlay) 31 painter.end() 32 33 label = QLabel() 34 label.setPixmap(QPixmap.fromImage(image)) 35 label.show() 36 37 sys.exit(app.exec_())
🌐
YouTube
youtube.com › brandon jacobson
Adding a Picture Overlay on Video with Python and OpenCV | #108 (S.H.A.N.E. Updates! #9) - YouTube
First, let me say thank you to all my subscribers for getting me to 2,000 subscribers. No matter how you got here, please watch the whole video to help my ch...
Published: October 30, 2020
Views: 12K