Python Tkinter GUI to Convert GIF to BMP or Vice-Versa Converter Using Pillow Library Full Project For Beginners
Welcome folks today in this blog post we will be converting gif to bmp
online converter using pillow
in python. All the full source code of application is shown below.
Get Started
In order to get started you need to install the following library using the pip
command as shown below
pip install tkinter
After installing this library make an app.py
file and copy paste the following code
app.py
from tkinter import *
from tkinter import filedialog as fd
import os
from PIL import Image
from tkinter import messagebox
root = Tk()
# naming the GUI interface to image_conversion_APP
root.title("Image_Conversion_App")
# creating the Function which converts the jpg_to_png
def gif_to_bmp():
global im
import_filename = fd.askopenfilename()
if import_filename.endswith(".gif"):
im = Image.open(import_filename)
export_filename = fd.asksaveasfilename(defaultextension = ".bmp")
im.save(export_filename)
messagebox.showinfo("Success", "File converted to .png")
else:
messagebox.showerror("Fail!!", "Error Interrupted!!!! Check Again")
def bmp_to_gif():
import_filename = fd.askopenfilename()
if import_filename.endswith(".bmp"):
im = Image.open(import_filename)
export_filename = fd.asksaveasfilename(defaultextension = ".gif")
im.save(export_filename)
messagebox.showinfo("Success", "File converted to .gif")
else:
messagebox.showerror("Fail!!", "Error Interrupted!!!! Check Again")
button1 = Button(root, text = "GIF_to_BMP",
width = 20, height = 2,
bg = "green", fg = "white",
font = ("helvetica", 12, "bold"),
command = gif_to_bmp)
button1.place(x = 120, y = 120)
button2 = Button(root, text = "BMP_to_GIF",
width = 20, height = 2,
bg = "green", fg = "white",
font = ("helvetica", 12, "bold"),
command = bmp_to_gif)
button2.place(x = 120, y = 220)
root.geometry("500x500+400+200")
root.mainloop()
Now if you execute the python
script by typing the below command as shown below
python app.py