Python Forum

Full Version: Problem editing images
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I am trying to make a program that edits images with python.
My difficulty is putting a png (no background) over the scene I want.
I am using the library "Pillow" and whenever I put the png where I want it, it shows up with a black background.
If someone can recommend me some better library or some way to do what I need I would appreciate it.
In this code, a png with a transparent background is superimposed onto a jpeg. On line five,background.paste(alien, (60, 40), alien), we are using the alpha channel for the alien image. If we were to write it like this: background.paste(alien, (60, 40)) we would get the black background affect that you noted. Hope this helps.
from PIL import Image

background = Image.open ('hwy7.jpg')
alien = Image.open ('alien.png')
background.paste(alien, (60, 40), alien)
background.save('superimposed.png',"PNG")
[attachment=1469][attachment=1470][attachment=1471]