Advertisement
biswasrohit20

4p

Jun 17th, 2021
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from PIL import Image, ImageDraw
  2. import math
  3. def create_background(size, color):
  4. r = color[0]
  5. g = color[1]
  6. b = color[2]
  7.  
  8. ri = math.floor((255-r)/size[0])
  9. gi = math.floor((255 - g) / size[0])
  10. bi = math.floor((255 - b) / size[0])
  11. img = Image.new("RGB", size)
  12. pixels = img.load()
  13. for i in range(size[0]):
  14. for j in range(size[1]):
  15. pixels[i,j] = (r,g,b)
  16. r += ri
  17. g += gi
  18. b += bi
  19. return img
  20.  
  21.  
  22.  
  23. def add_frame(pic, color):
  24. imageObject = Image.open(pic)
  25. degree_flippedImage = imageObject.transpose(Image.ROTATE_180)
  26. #degree_flippedImage.show()
  27. w,h = degree_flippedImage.size
  28. i = create_background((w+40,h+40), color)
  29. Image.Image.paste(i, degree_flippedImage, (20, 20))
  30. i.show()
  31.  
  32. add_frame("images.jpg", (130,10,20))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement