-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
182 lines (129 loc) · 5.67 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Import Modules
from tkinter import *
from tkinter import filedialog as fd
from PIL import Image
from tkinter import messagebox, OptionMenu, StringVar, Label, Button
import webbrowser
# Variable shortcuts for modules
root = Tk()
# Application Information
root.title("Image Converter 1.8") # name of window
root.resizable(False, False) # Cant resize window
frame1 = Frame(heigh=250, width=300, bg='teal') # bg1
frame1.pack(fill='both', expand=True)
frame1.grid
BottomFrame = Canvas(frame1, width="250", height="190",
relief=RIDGE, bd=2) # bottom frame
BottomFrame.place(x=25, y=30)
# start of website links
new = 1
url = "https://github.com/NotsoFrostyy"
def openweb():
webbrowser.open(url, new=new)
# end of website links
# start of jpg to png
def jpg_to_png():
global im1
import_filename = fd.askopenfilename(filetypes=[("JPG File", '.jpg')])
if import_filename.endswith(".jpg"):
im1 = Image.open(import_filename)
# where to save
export_filename = fd.asksaveasfilename(defaultextension=".png")
im1.save(export_filename)
messagebox.showinfo("success ", "your Image converted to Png")
else:
# error
messagebox.showerror("Error", "Input all Data")
# end of jpg to png
# start of png to jpg
def png_to_jpg():
global im1
import_filename = fd.askopenfilename(filetypes=[("PNG File", '.png')])
if import_filename.endswith(".png"):
im1 = Image.open(import_filename)
# where to save
export_filename = fd.asksaveasfilename(defaultextension=".jpg")
im1.save(export_filename)
messagebox.showinfo("success ", "your Image converted to Jpg")
else:
# error
messagebox.showerror("Error", "Input all Data")
# end of png to jpg
# start of jpg to pdf
def Jpg_to_Pdf():
global im1
import_filename = fd.askopenfilename(filetypes=[("JPG File", '.jpg')])
if import_filename.endswith(".jpg"):
im1 = Image.open(import_filename)
imgg = im1.convert("RGB")
imgg = fd.asksaveasfilename(defaultextension=".pdf")
im1.save(imgg)
messagebox.showinfo("success ", "your Image converted to pdf ")
else:
messagebox.showerror("Error", "Input all Data")
# end of jpg to pdf
def png_to_pdf():
global im1
import_filename = fd.askopenfilename(filetypes=[("PNG File", '.png')])
if import_filename.endswith(".png"):
im1 = Image.open(import_filename)
imgg = im1.convert("RGB")
imgg = fd.asksaveasfilename(defaultextension=".pdf")
im1.save(imgg)
messagebox.showinfo("success ", "your Image converted to pdf ")
else:
messagebox.showerror("Error", "Input all Data")
def png_to_ico():
global im1
import_filename = fd.askopenfilename(filetypes=[("PNG File", '.png')])
if import_filename.endswith(".png"):
im1 = Image.open(import_filename)
im1 = im1.resize((256, 256))
imgg = fd.asksaveasfilename(defaultextension=".ico")
im1.save(imgg, bitmap_format='bmp')
messagebox.showinfo("success ", "your Image converted to ico ")
else:
messagebox.showerror("Error", "Input all Data")
def jpg_to_ico():
global im1
import_filename = fd.askopenfilename(filetypes=[("JPG File", '.jpg')])
if import_filename.endswith(".jpg"):
im1 = Image.open(import_filename)
im1 = im1.resize((256, 256))
imgg = fd.asksaveasfilename(defaultextension=".ico")
im1.save(imgg, bitmap_format='bmp')
messagebox.showinfo("success ", "your Image converted to ico ")
else:
messagebox.showerror("Error", "Input all Data")
# start of buttons
button1 = Button(root, text="Jpg -> Png", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=jpg_to_png, relief=GROOVE)
button1.place(x=50, y=40)
button2 = Button(root, text="Png -> Jpeg", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=png_to_jpg, relief=GROOVE)
button2.place(x=160, y=40)
button3 = Button(root, text="Jpg -> Pdf", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=Jpg_to_Pdf, relief=GROOVE)
button3.place(x=50, y=80)
button5 = Button(root, text="Png -> Pdf", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=png_to_pdf, relief=GROOVE)
button5.place(x=160, y=80)
button6 = Button(root, text="Jpg -> Ico", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=jpg_to_ico, relief=GROOVE)
button6.place(x=50, y=120)
button7 = Button(root, text="Png -> Ico", width=9, height=1, bg="purple",
fg="white", font=("helvetica", 12, "bold"), command=png_to_ico, relief=GROOVE)
button7.place(x=160, y=120)
# end of button
# website button and placement and geometry of window
logo = Button(root, text="Frost Software", width=11, height=1, bg="teal",
fg="white", activebackground="teal", font=("helvetica", 10, "bold"), relief=SUNKEN, activeforeground="white")
logo.place(x=100, y=0)
Btn = Button(frame1, text="GITHUB", command=openweb, bg="Grey", fg="white",
width=8, height=1, font=("helvetica", 10, "bold"), relief=GROOVE)
Btn.place(x=155, y=195)
btn2 = Button(frame1, width=4, height=1, font=("helvetica", 10, "bold"),
text="Exit", bg='grey', fg='white', relief=GROOVE, command=root.destroy)
btn2.place(x=235, y=195)
root.geometry("300x250+400+200")
root.mainloop()