Advertisement
Peaser

image merge

Jul 31st, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. def avTwo(t1, t2):
  4.     return tuple([(a+b)/2 for a, b in [i for i in zip(t1, t2)]])
  5.  
  6. file1 = 'a.png'
  7. file2 = 'b.png'
  8. dimensions = (1920,1080)
  9.  
  10. pic1 = Image.open(file1).resize(dimensions)
  11. pic2 = Image.open(file2).resize(dimensions)
  12. p1dat = pic1.getdata()
  13. p2dat = pic2.getdata()
  14. p1dat = list(p1dat)
  15. p2dat = list(p2dat)
  16.  
  17. total = [avTwo(a, b) for a, b in zip(p1dat, p2dat)]
  18.  
  19. img = Image.new('RGB', dimensions, "white")
  20. img.putdata(total)
  21. img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement