Advertisement
1nikitas

Untitled

Mar 5th, 2022
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. def makeanagliph(file, delta):
  4. image = Image.open(file)
  5. height, lenght = image.size
  6. resolution = Image.new("RGB", (height, lenght), (0,0,0))
  7. p = resolution.load()
  8. p1 = image.load()
  9. for i in range(height):
  10. for j in range(lenght):
  11. if i < delta:
  12. r,g,b = p1[i,j]
  13. p[i,j] = 0, g, b
  14. else:
  15. g,b = p1[i,j][1:]
  16. r = p1[i-delta, j][0]
  17. p[i,j] = r,g,b
  18. resolution.save("res.jpg")
  19.  
  20. makeanagliph("1.jpg", 10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement