Skip to content
Advertisement

How to overlay two non-transparent images in Pillow

I’m trying to make a simple image manipulation function that applies a soviet flag filter to a profile picture. Both pictures are non-transparent. I have some code

JavaScript

That would work if either of the images were transparent. However, because my images are not transparent, it just shows the background. Also, the pictures have different resolutions, so it just shows the top left of the background. Is there a way to center & set the opacity of the profile picture, and then overlay it?

Advertisement

Answer

you may need to resize the images to match each other with the following:

JavaScript

then try using the blend() function:

JavaScript
Advertisement