Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. from PIL import Image
  2. from random import randint
  3. import randon
  4. import os
  5.  
  6. def ol(filenamez,num):
  7. body = Image.open(filenamez).convert("RGBA")
  8. path = r"/home/jack/Desktop/Images/thegirls/IMGS/"
  9. base_image = random.choice([
  10. y for y in os.listdir(path) if y.endswith(".jpg") or y.endswith(".png")
  11. if os.path.isfile(os.path.join(path, y))
  12. ])
  13. filenamez=(path+base_image)
  14. head = Image.open(filenamez).convert("RGBA")
  15. w,h = head.size
  16. UR=randint(20,w-250)
  17. LR= randint(20,h-150)
  18. U= randint(25,250)
  19. L =randint(25,150)
  20. U= randint(25,250)
  21. L =randint(25,150)
  22. UL = UR +U
  23. LL =LR+L
  24. headbox= (UR,LR,UL,LL)
  25. head.crop(headbox).save("head.png")
  26. head_crop = Image.open("head.png")
  27. body.paste(head_crop, (UR,LR))
  28. body.save("out2.png")
  29. body.save("EXP/"+num+"20out1.png")
  30.  
  31. IM = Image.new('RGBA',(1280,720),(0,0,0,0))
  32. IM.save("out2.png")
  33. for n in range(1,400):
  34. num = str(n)
  35. filenamez = "out2.png"
  36. ol(filenamez,num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement