-
Notifications
You must be signed in to change notification settings - Fork 0
/
imageFunctions.py
40 lines (29 loc) · 1.12 KB
/
imageFunctions.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
def convertToPNG(data): #converts to png if a jpg
newFile = data.projectDirectory + "/convertedToPNG.png"
userImage = Image.open(data.imagePath)
userImage.save(newFile)
return newFile
def checkSquare(data):
myImage = Image.open(data.imagePath)
w, h = myImage.size
return w == h
def resizeImage(data, imagePath, frameName, height):
#resizing image; primarily for filter previews
baseHeight = height
userImage = Image.open(imagePath)
hpercent = (baseHeight / float(userImage.size[1]))
wsize = int((float(userImage.size[0]) * float(hpercent)))
userImage = userImage.resize((wsize, baseHeight), Image.ANTIALIAS)
userImage.save(frameName)
data.previewWidth = wsize
data.previewHorizontalMargin = (data.width - 2*(data.margins +\
data.previewWidth))/3
while not os.path.exists(frameName):
data.resizingDone = False
data.resizingDone = True
def getFileName():
fileName = tkinter.filedialog.askopenfilename()
return fileName
def getDirectoryName():
path = tkinter.filedialog.askdirectory()
return path