Skip to content

Commit cee1a59

Browse files
Merge branch 'World-of-ML:main' into main
2 parents 376ccfd + 9b2ca8b commit cee1a59

18 files changed

+291
-0
lines changed

Image Grayscalling/Images/Image2.jpg

29.8 KB
Loading

Image Grayscalling/Images/Image3.jpg

81.4 KB
Loading

Image Grayscalling/Images/Image4.jpg

89.7 KB
Loading

Image Grayscalling/Images/Image5.jpg

132 KB
Loading

Image Grayscalling/Images/Image6.png

293 KB
Loading

Image Grayscalling/Images/image1.jpg

128 KB
Loading

Image Grayscalling/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
IMAGE GRAYSCALLING
2+
3+
GOAL </br>
4+
This is a simple image editor created in python programming language using tkinter.
5+
6+
DESCRIPTION </br>
7+
The goal is to convert colorful image provided by user to grayscale
8+
9+
To run this application download image_grayscale.py and resources in the same directory.
10+
11+
+ Open and run the file image_grayscale.py
12+
+ A black window will appear.
13+
+ Another window will open up in which the application will be running.
14+
+ Click on Upload Image.
15+
+ A Dialog box will appear to select image from files, upload a image.
16+
+ Small Preview of grayscaled image is displayed.
17+
+ Click on Download button to save the original Size image.:-D </br>
18+
For restart, you don't need to close the window, just upload another picture.
19+
20+
WHAT I HAD DONE </br>
21+
In this game, I implemented Two function that take image and provide option to download grayscaled image along with preview.
22+
The Main thing is, you don't need to download or install any library or modules.
23+
All things are packed in one application, so you need to just run that.
24+
25+
DEMONSTRATION </br>
26+
![image1](https://user-images.githubusercontent.com/94428262/208295887-a9c4bc75-1c66-400f-a338-2f42f7511fca.jpg)
27+
![Image2](https://user-images.githubusercontent.com/94428262/208295892-ecb945bb-0279-4aa9-9ca3-b0e67e1308ac.jpg)
28+
![Image3](https://user-images.githubusercontent.com/94428262/208295893-040a0611-131f-4f6d-8d0c-1ffd4b3c1d92.jpg)
29+
![Image4](https://user-images.githubusercontent.com/94428262/208295895-bc3fe59e-1814-44bc-9897-152806a43c0c.jpg)
30+
![Image5](https://user-images.githubusercontent.com/94428262/208295896-fdeb5c4f-c3a5-4d57-848f-fc4f87082478.jpg)
31+
![Image6](https://user-images.githubusercontent.com/94428262/208295897-e56ec2b9-b9c4-4514-a160-4db4987e1e75.png)
32+
33+
34+
I wish this application will be useful to you :-D
35+
36+
JATIN

Image Grayscalling/image_grayscale.py

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#Importing all the necessary modules
2+
import tkinter as tk
3+
from tkinter import filedialog
4+
from tkinter.filedialog import askopenfile
5+
6+
import PIL
7+
from PIL import Image, ImageTk
8+
9+
import cv2
10+
11+
#Setting up our gui
12+
gui = tk.Tk()
13+
# Size of the window
14+
gui.geometry("410x400")
15+
gui.title('Image Grayscalling 📷')
16+
gui.config(background="#FFB8A7")
17+
my_font1=('Times New Roman', 18, 'italic')
18+
19+
#Function to save the image, handler pointing to grayscale image is passed
20+
def savefile(imag):
21+
filename = filedialog.asksaveasfile(mode='wb', defaultextension=".png")
22+
if not filename:
23+
return
24+
imag.save(filename)
25+
26+
#Function to take input of image via file upload and convert it into grayscale
27+
def uploadFile():
28+
# type of files to select
29+
f_types = [('PNG Files','*.png'),
30+
('Jpg Files', '*.jpg')]
31+
f = tk.filedialog.askopenfilename(multiple=False,filetypes=f_types)
32+
col=1 # start from column 1
33+
row=3 # start from row 3
34+
35+
#Reading the image from location
36+
img = cv2.imread(f)
37+
38+
#with help of cv2.cvtColor() converting the image to grayscale
39+
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
40+
#Since return type of above is a numpy array, so using Pillow to convert to image
41+
imagePIL = PIL.Image.fromarray(gray_img)
42+
#Making the copy of image, it will be used in saving to save the grayscale image with original dimension
43+
duplicate = imagePIL.copy()
44+
45+
#Resizing image to display in gui
46+
imagePIL.thumbnail((400,250))
47+
img = ImageTk.PhotoImage(image = imagePIL)
48+
49+
#creating a label to display the image
50+
Img =tk.Label(gui)
51+
Img.grid(row=row,column=col)
52+
# keep a reference! by attaching it to a widget attribute
53+
Img.image = img
54+
# Show Image
55+
Img['image']=img
56+
57+
# start new line after third column
58+
if(col==3):
59+
# start wtih next row
60+
row=row+1
61+
# start with first column
62+
col=1
63+
# within the same row
64+
else:
65+
# increase to next column
66+
col=col+1
67+
68+
#Calling the save function to save the file
69+
button = tk.Button(gui, text="Download🔽", command=lambda:savefile(duplicate), background="#CAF4F4")
70+
button.grid(row=10, column=1, columnspan=4)
71+
72+
#Creating some empty space initially
73+
Empty = tk.Label(gui,text='',width=30,font=my_font1, background="#FFB8A7")
74+
Empty.grid(row=1,column=1,columnspan=4)
75+
76+
#Button to take image via file upload
77+
b1 = tk.Button(gui, text='Upload Image⬆️',
78+
width=20,command = lambda:uploadFile(), background="#CAF4F4")
79+
b1.grid(row=2,column=1,columnspan=4)
80+
#calling the function while clicking the button
81+
82+
83+
gui.mainloop() # Keep the window open

Img To PDF/Images/cmdexample.jpeg

102 KB
Loading

Img To PDF/Images/file 0.pdf

168 KB
Binary file not shown.
32.2 KB
Loading

Img To PDF/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*IMG to PDF converter*
2+
3+
GOAL
4+
5+
To create a pdf file of an jpg or jpeg file using Tkinter and Python
6+
7+
DESCRIPTION
8+
This project aims to convert jpeg and jpg files to pdf.
9+
10+
Control Keys:
11+
Open the command terminal and run the code imgtopdf.py
12+
Then follow the on screen commands.
13+
14+
How I Made it
15+
16+
I used python libraries such as PIL and img2pdf and TKinter for this project.
17+
18+
LIBRARIES NEEDED
19+
20+
img2pdf
21+
Pillow
22+
23+
24+
DEMONSTRATION
25+
26+
27+
![image](https://user-images.githubusercontent.com/98964611/208297652-9dc519d8-4dbb-4b22-8401-14abde833b51.png)
28+
![image](https://user-images.githubusercontent.com/98964611/208305393-d84240a9-becb-4a5c-971f-49755c113535.png)
29+
30+
31+
32+
33+
Pundarikaksha
34+
GITHUB: pundarikaksha7
35+
Linkedin: linkedin.com/in/pundarikaksha7

Img To PDF/imgtopdf.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Import Module
2+
from tkinter import *
3+
from tkinter.filedialog import askopenfilenames
4+
import img2pdf
5+
from PIL import Image
6+
7+
# Create Object
8+
root = Tk()
9+
# set Geometry
10+
root.geometry('400x200')
11+
12+
def select_file():
13+
global file_names
14+
file_names = askopenfilenames(initialdir = "/",
15+
title = "Select File")
16+
17+
# IMAGE TO PDF
18+
def image_to_pdf():
19+
for index, file_name in enumerate(file_names):
20+
with open(f"file {index}.pdf", "wb") as f:
21+
image = Image.open(file_name)
22+
pdf_bytes = img2pdf.convert(image.filename)
23+
f.write(img2pdf.convert(image.filename))
24+
image.close()
25+
f.close()
26+
print('Converted')
27+
28+
29+
# Add Labels and Buttons
30+
Label(root, text = "IMG TO PDF",
31+
font = "italic 15 bold").pack(pady = 10)
32+
33+
Button(root, text = "Select Image",
34+
command = select_file, font = 14).pack(pady = 10)
35+
36+
frame = Frame()
37+
frame.pack(pady = 20)
38+
39+
Button(frame, text = "Image to PDF",
40+
command = image_to_pdf,
41+
relief = "solid",
42+
bg = "white", font = 15).pack(side = LEFT, padx = 10)
43+
44+
45+
# Execute Tkinter
46+
root.mainloop()

TODO App/images/2022-12-17 (1).png

29 KB
Loading

TODO App/images/todo ui.png

25.5 KB
Loading

TODO App/main.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from tkinter.font import Font as f
2+
from tkinter import *
3+
4+
5+
root = Tk()
6+
root.geometry('500x500')
7+
root.title('TODO App')
8+
9+
my_font = f(
10+
family = "Arial",
11+
size = 16,
12+
weight = "bold"
13+
)
14+
15+
my_frame = Frame(root)
16+
my_frame.pack(pady=10)
17+
18+
my_list = Listbox(
19+
my_frame,
20+
font = my_font,
21+
width = 25,
22+
height = 5,
23+
bg = "#deecec",
24+
bd = 0,
25+
fg = "#464646",
26+
selectbackground ="#c8a2d6",
27+
highlightthickness = 0 ,
28+
activestyle = "none"
29+
)
30+
my_list.pack(side = LEFT, fill = BOTH)
31+
dummy_list = ["Fast API", "TKinter", "Python", "Open Source"]
32+
for item in dummy_list :
33+
my_list.insert(END, item)
34+
35+
36+
37+
my_scrollbar = Scrollbar(my_frame)
38+
my_scrollbar.pack(side = RIGHT, fill = BOTH)
39+
40+
my_list.config(yscrollcommand=my_scrollbar.set)
41+
my_scrollbar.config(command=my_list.yview)
42+
43+
# creating entry box
44+
my_entry = Entry(root,font=("Arial", 20))
45+
my_entry.pack(pady = 20)
46+
# buttons frame
47+
button_frame = Frame(root)
48+
button_frame.pack(pady = 20)
49+
50+
# button functions
51+
def add_item():
52+
new_item = my_entry.get()
53+
if len(new_item) >=1 :
54+
my_list.insert(END, my_entry.get())
55+
my_entry.delete(0, END)
56+
def delete_item():
57+
my_list.delete(ANCHOR)
58+
59+
60+
# adding buttons
61+
dlt_button = Button(button_frame, text = "Delete", command = delete_item, bg = "#fb6b6c", fg = 'white')
62+
add_button = Button(button_frame,width=5, text = "Add", command = add_item, bg="#50e3a4", fg = 'white')
63+
bfont = f(family='Arial', weight = 'bold', size = 14)
64+
dlt_button['font'] = bfont
65+
add_button['font'] = bfont
66+
dlt_button.grid(row = 0, column = 1, padx = 20)
67+
add_button.grid(row = 0, column =0)
68+
69+
70+
root.mainloop()

TODO App/readme.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
**TODO App**
2+
<hr>
3+
4+
**Features**
5+
6+
In this app, the user will be able to do following:
7+
8+
- Create (add) a new task or adding a new ToDo in the ToDo List App.
9+
- See all the tasks or View all the ToDos that were added to the app.
10+
- Delete any ToDo from the list of ToDos.
11+
- Exit from the app.
12+
13+
**Approach**
14+
15+
This app build using `tkinter 3.9.14` which is a python library
16+
17+
18+
**Durga Vamsi Krishna**[https://github.com/vamsikrishnarh7/]

TODO App/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The required library is:
2+
3+
tkinter - 3.9.14

0 commit comments

Comments
 (0)