Skip to content

Instantly share code, notes, and snippets.

@iml1111
Created April 28, 2022 14:05
Show Gist options
  • Save iml1111/4e97d217e57dbe5b6ae87965932db034 to your computer and use it in GitHub Desktop.
Save iml1111/4e97d217e57dbe5b6ae87965932db034 to your computer and use it in GitHub Desktop.
Gravatar_example
import os
import requests
import subprocess
import hashlib
__AUTHOR__ = "IML"
# TEST
def md5_hex(text):
m = hashlib.md5()
m.update(text.encode('ascii', errors='ignore'))
return m.hexdigest()
def convert(input_text = "test", size = 300):
output_file = os.path.join(input_text + '.png')
if not os.path.exists(output_file):
grav_url = "http://www.gravatar.com/avatar/" + \
md5_hex(input_text) + "?d=identicon&s=" + str(size)
r = requests.get(grav_url)
if r.ok:
with open(output_file, 'wb') as img:
img.write(r.content)
print("complete! Here Image URL.")
print(grav_url)
if __name__ == '__main__':
convert(input("Input Your Text: "),
int(input("Input Size(Only int): ")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment