-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (40 loc) · 1.36 KB
/
main.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
44
45
46
47
48
49
from tkinter import *
from tkinter import filedialog
import os
os.system("clear")
app = Tk()
direct = StringVar()
files = []
formats = ["jpeg","tiff","png","gif","jp2","pict","bmp","qtif","psd","sgi","tga"]
v = StringVar()
v.set("jpeg")
def selectDirectory():
app.filename = filedialog.askdirectory()
print(app.filename)
files.append(os.listdir(str(app.filename)))
direct.set("Directory: " + str(app.filename))
os.chdir(str(app.filename))
os.system("ls")
def reformat():
print(v.get())
for f in files[0]:
data = f.split(".")
print(f)
os.system("sips -s format " + v.get() + " " + f + " --out " + data[0] + "." + v.get())
os.remove(f)
def build():
chooseDirectoryFrame = Frame(app)
chooseDirectoryFrame.pack(side=TOP)
Button(chooseDirectoryFrame, text="Select Directory", command=selectDirectory).pack(side=LEFT)
direct.set("Directory: ")
Label(chooseDirectoryFrame, textvariable=direct).pack(side=LEFT)
imageFormatOptionsFrame = Frame(app)
imageFormatOptionsFrame.pack()
for text in formats:
Radiobutton(imageFormatOptionsFrame, text=text, variable=v, value=text).pack(side=LEFT)
submitFrame = Frame(app)
submitFrame.pack(side=BOTTOM)
Button(submitFrame, text="Reformat", command=reformat).pack(side=LEFT)
app.title("Image Reformatter")
app.mainloop()
build()