Home PROJECTS Image Converter GUI with Python Project with Source Code

Image Converter GUI with Python Project with Source Code

0

Image Converter GUI with Python Project with Source Code – Image Converter with Python To create an Image converter GUI with Python, I will use the Tkinter library in Python which is the best known Python framework for building GUI application. Other than Tkinter we also need PIL library in Python which stands for Python Imaging Library.

Now let’s see how to create an application to convert a PNG image to JPG:

import tkinter as tk
from tkinter import filedialog
from PIL import Image

root = tk.Tk()
canvas1 = tk.Canvas(root, width=300, height=250, bg='azure3', relief='raised')
canvas1.pack()

label1 = tk.Label(root, text="Image Converter", bg='azure3')
label1.config(font=('helvetica', 20))
canvas1.create_window(150, 60, window=label1)

def getPNG():
    global im1
    import_file_path = filedialog.askopenfilename()
    im1 = Image.open(import_file_path)

browse_png = tk.Button(text="Select PNG file", command=getPNG, bg="royalblue", fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 130, window=browse_png)

def convert():
    global im1
    export_file_path = filedialog.asksaveasfilename(defaultextension='.jpg')
    im1.save(export_file_path)

saveasbutton = tk.Button(text="Convert PNG to JPG", command=convert, bg='royalblue', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 180, window=saveasbutton)
root.mainloop()


NOTE – In order to run the project of Python, you have to download Python IDLE or Pycharam. In the video I have explained how to download and install it.

Download and Install Python

Download and install Pycharm

TOP 50+ PYTHON PROJECT WITH SOURCE CODE FREE

Additional Reading

READ MORE

If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 🙂 Keep Learning !

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version