Skip to content

Commit c1d2358

Browse files
Converts Jpeg to png
1 parent f1ae573 commit c1d2358

5 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# CONVERT_JPEG_to_PNG
2+
3+
This project contains a simply python script to change file extension from .jpeg to .png
4+
5+
## Requirements
6+
Pillow module
7+
8+
`pip install pillow`
9+
10+
## Two methods:
11+
12+
I accomplished this task in two ways
13+
### Using Terminal
14+
- Add the image in jpeg format with name as 'input' in this folder.
15+
- Run converter_terminal.py script
16+
- output image will be generated in this folder
17+
18+
### Using GUI
19+
Just run the converter_GUI.py script and pick any jpeg image from any location and then press 'Convert Jpeg to Png'
20+
21+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import tkinter as tk
2+
from tkinter import filedialog
3+
from tkinter import messagebox
4+
from PIL import Image
5+
6+
7+
root= tk.Tk()
8+
9+
canvas1 = tk.Canvas(root, width = 300, height = 250, bg = 'orange', relief = 'raised')
10+
canvas1.pack()
11+
12+
label1 = tk.Label(root, text='File Converter', bg = 'lightsteelblue2')
13+
label1.config(font=('helvetica', 20))
14+
canvas1.create_window(150, 60, window=label1)
15+
root.title('Converter')
16+
17+
def getJPG ():
18+
global im1
19+
20+
import_file_path = filedialog.askopenfilename()
21+
im1 = Image.open(import_file_path)
22+
23+
browseButton_JPG = tk.Button(text=" Import JPEG File ", command=getJPG, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
24+
canvas1.create_window(150, 130, window=browseButton_JPG)
25+
26+
def convertToPNG ():
27+
global im1
28+
29+
export_file_path = filedialog.asksaveasfilename(defaultextension='.png')
30+
im1.save(export_file_path)
31+
32+
saveAsButton_PNG = tk.Button(text='Convert JPEG to PNG', command=convertToPNG, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
33+
canvas1.create_window(150, 180, window=saveAsButton_PNG)
34+
35+
root.mainloop()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os
2+
from PIL import Image
3+
4+
5+
dir_path = os.path.dirname(os.path.realpath(__file__))
6+
7+
im1 = Image.open('input.jpeg')
8+
9+
im1.save('output.png')
680 KB
Loading
4.7 MB
Loading

0 commit comments

Comments
 (0)