forked from NicholasChase/primitive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
43 lines (37 loc) · 914 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import urllib.request
import json
import tkinter as tk
from re import search
import PIL
from PIL import ImageTk as a
from PIL import Image
def getImage(url, filePath):
print("This is file path" + filePath)
urllib.request.urlretrieve(url, filePath)
def previewImage(path):
img = Image.open(path)
img = img.resize((250,250),Image.ANTIALIAS)
img = a.PhotoImage(img)
return img
def checkOutPath(path):
if search("png", path):
return True
elif search("jpg", path):
return True
elif search("svg", path):
return True
elif search("gif", path):
return True
else:
return False
def getExtension(url):
if search(".png", url):
return '.png'
elif search(".jpg", url):
return '.jpg'
elif search(".svg", url):
return '.svg'
elif search(".gif", url):
return '.gif'
else:
return ''