Skip to content

Commit 47bd8e7

Browse files
Merge pull request avinashkranjan#888 from Amit366/Image
Image viewing GUI
2 parents 16f8540 + ba824f5 commit 47bd8e7

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

Image_Viewing_GUI/Readme.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# <b>Image Viewing GUI</b>
2+
3+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
4+
5+
## Image Viewing GUI Functionalities : 🚀
6+
7+
- Enter the directory for the images.
8+
- Now run the script to see all the images one by one.
9+
10+
## Image Viewing GUI Instructions: 👨🏻‍💻
11+
12+
### Step 1:
13+
14+
Open Termnial 💻
15+
16+
### Step 2:
17+
18+
Locate to the directory where python file is located 📂
19+
20+
### Step 3:
21+
22+
Run the command: python script.py/python3 script.py 🧐
23+
24+
### Step 4:
25+
26+
Sit back and Relax. Let the Script do the Job. ☕
27+
28+
## Requirements
29+
30+
- tkinter
31+
- os
32+
- PIL
33+
34+
## Author
35+
36+
Amit Kumar Mishra

Image_Viewing_GUI/script.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from tkinter import *
2+
from PIL import Image, ImageTk
3+
import os
4+
5+
root = Tk()
6+
root.geometry("600x600")
7+
8+
def resize_image(root, copy_image, label1):
9+
new_height = 600
10+
new_width = 600
11+
image=copy_image.resize((new_width,new_height))
12+
photo=ImageTk.PhotoImage(image)
13+
label1.configure(image=photo)
14+
label1.image=photo
15+
16+
def next():
17+
global n
18+
global itemslist
19+
n=(n+1)%len(itemslist)
20+
img1 = itemslist[n]
21+
22+
image = Image.open(path+"/"+img1)
23+
copy_image=image.copy()
24+
photo=ImageTk.PhotoImage(image)
25+
26+
label=Label(root,image=photo)
27+
label.bind('<configure>',resize_image(root, copy_image, label1))
28+
label.pack()
29+
30+
def previous():
31+
global n
32+
global itemslist
33+
n=(n-1)%len(itemslist)
34+
img1 = itemslist[n]
35+
36+
image = Image.open(path+"/"+img1)
37+
copy_image=image.copy()
38+
photo=ImageTk.PhotoImage(image)
39+
40+
label2=Label(root,image=photo)
41+
label2.bind('<configure>',resize_image(root, copy_image, label1))
42+
label2.pack()
43+
44+
45+
n=0
46+
path = input(r"Enter path for the image folder: ")
47+
itemslist = os.listdir(path)
48+
img1 = itemslist[n]
49+
50+
image = Image.open(path+"/"+img1)
51+
copy_image=image.copy()
52+
photo=ImageTk.PhotoImage(image)
53+
54+
label1=Label(root,image=photo)
55+
label1.bind('<configure>',resize_image(root, copy_image, label1))
56+
label1.pack()
57+
58+
btn1 = Button(root,text="next",width=5,height=10,command=next)
59+
btn1.place(x=570,y=150)
60+
61+
btn1 = Button(root,text="prev",width=5,height=10,command=previous)
62+
btn1.place(x=0,y=150)
63+
64+
root.mainloop()
65+

0 commit comments

Comments
 (0)