a little cleanup
This commit is contained in:
parent
b9b1a3bd84
commit
9eefa13058
|
@ -1,9 +1,10 @@
|
|||
# Script to grab the current Gravatar image for a given email address
|
||||
import hashlib
|
||||
import requests
|
||||
import sys
|
||||
from PIL import Image
|
||||
|
||||
# allow script to receive an argument
|
||||
import sys
|
||||
email_input = sys.argv[1]
|
||||
|
||||
def hash_email(email):
|
||||
|
@ -15,27 +16,18 @@ def fetch_gravatar(email, size=1000, rating="g"):
|
|||
response = requests.get(url)
|
||||
return response.content
|
||||
|
||||
|
||||
|
||||
def save_gravatar(email, size=1000, rating="g"):
|
||||
with open(f"gravatar-{size}.png", "wb") as f: # Use "wb" mode for binary write
|
||||
f.write(fetch_gravatar(email, size))
|
||||
# Convert to webp format
|
||||
import PIL
|
||||
from PIL import Image
|
||||
|
||||
def convert_to_webp(size=1000):
|
||||
im = Image.open(f"gravatar-{size}.png")
|
||||
im.save(f"gravatar-{size}.webp")
|
||||
|
||||
def variety_of_sizes(email,sizes=[1000,1500,800,300,200,150,100]):
|
||||
def variety_of_sizes(email, sizes=[1000, 1500, 800, 300, 200, 150, 100]):
|
||||
for x in sizes:
|
||||
save_gravatar(email, size=x)
|
||||
convert_to_webp(size=x)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print( hash_email(email))
|
||||
variety_of_sizes(email_input)
|
||||
variety_of_sizes(email_input)
|
Loading…
Reference in New Issue
Block a user