python image layers 1

python image layers

from PIL import Image

background = Image.open("test1.png")
foreground = Image.open("test2.png")

background.paste(foreground, (0, 0), foreground)
background.show()

Here is what the above code is Doing:
1. Open the background image
2. Open the foreground image
3. Paste the foreground image onto the background image at the coordinates (0, 0)
4. Show the background image

Similar Posts