fork download
  1. def get_avatar(name=''):
  2. gr = Image.new('RGB',(261, 261), (0, 0, 0))
  3. x = 1
  4. y = 1
  5. x1 = 65
  6. y1 = 65
  7. for dx in range(0, 4):
  8. for dy in range(0, 4):
  9. r = randint(0, 255)
  10. g = randint(0, 255)
  11. b = randint(0, 255)
  12. block = Image.new('RGB',(64, 64), (r, g, b))
  13. area = (x, y, x1, y1)
  14. gr.paste(block, area)
  15. x+=65
  16. x1+=65
  17. x = 1
  18. x1 = 65
  19. y+=65
  20. y1+=65
  21. if name == '':
  22. name = (''.join(sample(''.join([chr(i) for i in range(97, 123)])*10
  23. + str(randint(11111, 99999))*10, 8)))+'.jpg'
  24. gr.save(name)
  25.  
  26. if __name__=='__main__':
  27. from PIL import Image
  28. from random import randint, sample
  29. get_avatar()
Runtime error #stdin #stdout #stderr 0.07s 13968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 29, in <module>
  File "./prog.py", line 24, in get_avatar
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 1679, in save
    fp = builtins.open(fp, "wb")
PermissionError: [Errno 13] Permission denied: 'ti6wks9j.jpg'