How to apply paper background in python using pillow?

I’m trying to put paper background with this picture to create an old image, also some colors (colors are not important). I used to do it in GIMP by putting paper as layer above (layermask) and and putting down transparency. Don’t have any ideas how to do it in python, do you?

enter image description here Photo by Julia Maior on Unsplash

enter image description here Photo by amir rabiee on Unsplash

Answer

You can use Pillow Library for Python. It is a modern forked version of PIL used for image processing.

Only install Pillow and not PIL. They are two seperate packages.

python3 -m pip install –upgrade Pillow

Here is the offical Github Repo: https://github.com/python-pillow/Pillow

I’ve used your images to make what I believe you wanted.

#!/usr/bin/python3
from PIL import Image

Im = Image.open("car.jpg")

Im2 = Image.open("crumble_paper.jpg").convert(Im.mode)
Im2 = Im2.resize(Im.size)

img = Image.blend(Im,Im2,0.3)
img.save('crumble_paper_car.jpg', 'JPEG')

enter image description here