Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem editing images
#1
Question 
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.
Reply
#2
take a look at: https://stackoverflow.com/q/50822924
ielcraft1 likes this post
Reply
#3
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")
           
ielcraft1 and Pedroski55 like this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Editing/Problem with outputs stanthaman42 7 4,210 Jul-11-2018, 05:30 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020