πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step)

πŸ‘‰ Full source code:
https://github.com/rogers-cyber/python-tiny-tools/blob/main/63-Image-resizer/ImageConvertPRO.py

🧠 What You’ll Build

In this tutorial, we’ll create a modern desktop app that can:

πŸ“‚ Add images (files, folders, drag & drop)

πŸ–Ό P…


This content originally appeared on DEV Community and was authored by Mate Technologies

πŸ‘‰ Full source code:
https://github.com/rogers-cyber/python-tiny-tools/blob/main/63-Image-resizer/ImageConvertPRO.py

🧠 What You’ll Build

In this tutorial, we’ll create a modern desktop app that can:

πŸ“‚ Add images (files, folders, drag & drop)

πŸ–Ό Preview thumbnails

πŸ”„ Convert formats (PNG, JPEG, WEBP, etc.)

πŸ“ Resize images

πŸ’Ύ Save conversion history (SQLite)

⚑ Run conversions in background (no freezing UI)

πŸ“¦ Step 1: Install Dependencies
pip install pillow ttkbootstrap tkinterdnd2
πŸ” Why we need them:

Pillow β†’ image processing

ttkbootstrap β†’ modern UI styling

tkinterdnd2 β†’ drag & drop support

πŸ“ Step 2: Project Setup

Create a Python file:

image_convert_pro.py
βš™οΈ Step 3: Import Libraries

import os
import sys
import sqlite3
from threading import Thread
from PIL import Image, ImageTk

🧠 Explanation:

os, sys β†’ file handling

sqlite3 β†’ local database

Thread β†’ run tasks without freezing UI

PIL β†’ image processing

Handle Image Resampling (Important!)

try:
    from PIL import ImageResampling
    RESAMPLE = ImageResampling.LANCZOS
except:
    RESAMPLE = Image.LANCZOS

βœ” This ensures compatibility across Pillow versions.

🎨 Step 4: Import UI Libraries

import ttkbootstrap as tb
from ttkbootstrap.constants import *
from tkinter import filedialog, messagebox, Listbox, Canvas, Scrollbar
from tkinterdnd2 import TkinterDnD, DND_FILES

🏷 Step 5: App Configuration

APP_NAME = "ImageConvert PRO"

APP_VERSION = "1.1"
πŸ“‚ Step 6: Setup Paths

BASE_DIR = os.path.dirname(sys.argv[0])
DB_NAME = os.path.join(BASE_DIR, "snapconvert.db")
OUTPUT_DIR = os.path.join(BASE_DIR, "converted")

πŸ—„ Step 7: Create Database
Create table

def init_db():
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute("""CREATE TABLE IF NOT EXISTS history(
        id INTEGER PRIMARY KEY,
        name TEXT,
        original TEXT,
        converted TEXT)""")
    conn.commit()
    conn.close()

Insert data

def insert_db(name, orig, conv):
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute("INSERT INTO history(name, original, converted) VALUES(?,?,?)",(name,orig,conv))
    conn.commit()
    conn.close()
Fetch history
def fetch_db():
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute("SELECT name, original, converted FROM history ORDER BY id DESC")
    rows = c.fetchall()
    conn.close()
    return rows

Clear history

def clear_history():
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute("DELETE FROM history")
    conn.commit()
    conn.close()

ℹ️ Step 8: About Dialog

def show_about():
    messagebox.showinfo(
        f"About {APP_NAME}",
        f"{APP_NAME} v{APP_VERSION}\n\n"
        "Professional Image Converter\n\n"
        "Β© 2026 Mate Technologies\n"
        "https://matetools.gumroad.com"
    )

⚑ Step 9: Image Processing Worker (Core Logic)
def worker(images, fmt, out, quality, resize, keep, progress, finish):
os.makedirs(out, exist_ok=True)
πŸ” Loop through images

    for i, path in enumerate(images):
        try:
            with Image.open(path) as img:
Resize (optional)
                if resize > 0:
                    img = img.resize((resize, resize), RESAMPLE)
Convert format safely
                if fmt == "JPEG" and img.mode in ("RGBA","P"):
                    img = img.convert("RGB")
Save file
                img.save(out_path, fmt)
Update progress
        progress(int((i+1)/total*100))

Finish callback
finish(count)
πŸ–₯ Step 10: Build Main App Class

class App:
    def __init__(self):
        self.root = TkinterDnD.Tk()
        self.root.title(APP_NAME)
        self.root.geometry("1200x750")

πŸ“‹ Step 11: Menu Bar

def create_menu(self):
    menubar = tb.Menu(self.root)
    help_menu = tb.Menu(menubar, tearoff=0)
    help_menu.add_command(label="About", command=show_about)
    menubar.add_cascade(label="Help", menu=help_menu)
    self.root.config(menu=menubar)

🧩 Step 12: Build UI Layout

We divide into 3 sections:

LEFT β†’ File list

self.listbox = Listbox(left, bg="#1e1e1e", fg="white")

Buttons:

Add Images

Add Folder

Remove

Clear

CENTER β†’ Image preview

self.canvas = Canvas(center, bg="#121212")

βœ” Scrollable gallery

RIGHT β†’ Settings panel

self.format = tb.Combobox(right, values=["PNG","JPEG","WEBP","BMP","TIFF"])

Options:

Format

Quality

Resize

Keep filename

Convert button
tb.Button(right, text="πŸš€ Convert", command=self.convert)
πŸ–± Step 13: Drag & Drop Support

self.root.drop_target_register(DND_FILES)
self.root.dnd_bind("<<Drop>>", self.drop)

πŸ–Ό Step 14: Render Image Gallery

def render_gallery(self):
    for i, path in enumerate(self.images[:50]):
        img = Image.open(path)
        img.thumbnail((150,150))

βœ” Displays thumbnails in grid layout

πŸ”„ Step 15: Convert Images (Threaded)

def convert(self):
    Thread(target=worker, args=(...), daemon=True).start()

🧠 Why threading?

Without it:
❌ UI freezes
With it:
βœ… Smooth experience

πŸ“Š Step 16: Progress Bar

self.progress = tb.Progressbar(right)

Update:

self.progress.config(value=v)

πŸ—‘ Step 17: Delete History

def delete_history(self):
    if messagebox.askyesno("Confirm", "Delete all history?"):
        clear_history()

▢️ Step 18: Run the App

if __name__ == "__main__":
    init_db()
    App().run()

πŸŽ‰ Final Result

You now have a fully functional desktop app with:

βœ… Modern UI
βœ… Drag & drop
βœ… Image conversion
βœ… Resize + quality control
βœ… History tracking
βœ… Multithreading

πŸ’‘ Bonus Ideas (for improvement)

πŸ” Add search in history

πŸŒ™ Light/Dark mode toggle

πŸ“¦ Export history to CSV

⚑ Batch rename rules

🧠 AI auto image optimization


This content originally appeared on DEV Community and was authored by Mate Technologies


Print Share Comment Cite Upload Translate Updates
APA

Mate Technologies | Sciencx (2026-04-05T05:37:00+00:00) πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step). Retrieved from https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/

MLA
" » πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step)." Mate Technologies | Sciencx - Sunday April 5, 2026, https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/
HARVARD
Mate Technologies | Sciencx Sunday April 5, 2026 » πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step)., viewed ,<https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/>
VANCOUVER
Mate Technologies | Sciencx - » πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/
CHICAGO
" » πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step)." Mate Technologies | Sciencx - Accessed . https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/
IEEE
" » πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step)." Mate Technologies | Sciencx [Online]. Available: https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/. [Accessed: ]
rf:citation
» πŸš€ Build a Professional Image Converter GUI in Python (Step-by-Step) | Mate Technologies | Sciencx | https://www.scien.cx/2026/04/05/%f0%9f%9a%80-build-a-professional-image-converter-gui-in-python-step-by-step/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.