SHARE
TWEET

Untitled

a guest Feb 16th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import matplotlib.pyplot as plt
  2. from PIL import Image
  3.  
  4.  
  5. img = Image.open("C:\\Users\Shadow\Desktop\JohnTravolta\GreenScreen.png")
  6. print(img.size)
  7. img.convert("RGBA")
  8.  
  9. background = Image.open('C:\\Users\Shadow\Desktop\JohnTravolta\Background.png')
  10. print(background.size)
  11. size = img.size
  12. background.convert("RGBA")
  13.  
  14. background = background.resize(size, Image.ANTIALIAS)
  15. print(background.size)
  16.  
  17. pixelData = img.load()
  18.  
  19. width,height = img.size
  20. for y in range(height):
  21.     for x in range(width):
  22.         if pixelData[x,y] == (103,254,3,255) :
  23.             pixelData[x,y] = (255,255,255,0)
  24.  
  25.  
  26.  
  27. background.paste(img, (0, 0), img)
  28. background.save('new_image.png', "PNG")
  29.  
  30. plt.imshow(background)
  31. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top