-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
73 lines (48 loc) · 1.55 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
import tkinter as tk
from tkinter.filedialog import askopenfilename
from PIL import Image
from decode import decode
from encode import encode
window = tk.Tk()
window.title("PGH's Steganography")
window.resizable(False, False)
def get_image():
file_location = askopenfilename()
lbl_image.config(text="Image: "+ file_location)
global image
image = Image.open(file_location)
global pixels
pixels = list(image.getdata())
global width, height
width, height = image.size
def decode_image():
txt_message.delete('1.0', tk.END)
message = decode(pixels)
txt_message.insert(1.0, message)
def encode_image():
message = txt_message.get("1.0","end")
txt_message.delete('1.0', tk.END)
encode(image, pixels, height, width, message)
#image = Image.open('image.jpeg')
#width, height = image.size
# choose image
frm_upload = tk.Frame(window)
btn_upload = tk.Button(text="Choose Image", command = get_image)
btn_upload.pack(side=tk.TOP, anchor=tk.NW)
lbl_image = tk.Label(text="Image: ")
lbl_image.pack(side=tk.TOP, anchor=tk.W)
# message area
lbl_message = tk.Label(text="Message",font=("Helvetica", 20, 'bold'))
txt_message = tk.Text()
# encode and decoding
frm_button_pair = tk.Frame(window)
btn_encode = tk.Button(frm_button_pair, text="Encode", command = encode_image)
btn_encode.pack(side = tk.RIGHT)
btn_decode = tk.Button(frm_button_pair, text="Decode", command = decode_image)
btn_decode.pack(side = tk.LEFT)
# packing
frm_upload.pack()
lbl_message.pack()
txt_message.pack()
frm_button_pair.pack()
window.mainloop()