πŸš€ AI Image Resizer & Converter | Resize & Convert Images in 1 Click (Python Tkinter GUI)

Demo :


Click Video πŸ‘‡πŸ‘‡πŸ‘‡

















Features to Highlight in Blogger Post:

  • πŸ“‚ Folder Structure (Step-by-Step Guide)

  • πŸ”₯ Full Python Code (Modern + Stylish GUI)

  • πŸ“Œ Installation Steps & Dependencies

  • πŸ“Ί YouTube Shorts Embed for Demo

  • πŸ“₯ Downloadable Source Code


Code :


import os

import customtkinter as ctk

from tkinter import filedialog, messagebox

from PIL import Image


# 🌟 Initialize App

ctk.set_appearance_mode("dark")  # Modes: "dark", "light"

ctk.set_default_color_theme("blue")  # Themes: "blue", "green", "dark-blue"


app = ctk.CTk()

app.title("AI Image Resizer & Converter")

app.geometry("600x500")


selected_files = []


# πŸ“‚ **File Selection Function**

def select_files():

    global selected_files

    files = filedialog.askopenfilenames(filetypes=[("Images", "*.jpg;*.png;*.webp")])

    if files:

        selected_files = files

        label_status.configure(text=f"Selected {len(files)} images", text_color="green")


# πŸ”„ **Resize & Convert Function**

def process_images():

    if not selected_files:

        messagebox.showerror("Error", "No images selected!")

        return


    output_format = dropdown_format.get().lower()

    width = int(entry_width.get()) if entry_width.get().isdigit() else None

    height = int(entry_height.get()) if entry_height.get().isdigit() else None


    output_folder = filedialog.askdirectory()

    if not output_folder:

        return


    for file in selected_files:

        img = Image.open(file)

        if width and height:

            img = img.resize((width, height))

        new_file = os.path.join(output_folder, os.path.splitext(os.path.basename(file))[0] + f".{output_format}")

        img.save(new_file, format=output_format.upper())


    messagebox.showinfo("Success", f"Images saved to {output_folder}")


# 🎨 **GUI Layout**

label_title = ctk.CTkLabel(app, text="AI Image Resizer & Converter", font=("Arial", 22, "bold"))

label_title.pack(pady=20)


btn_select = ctk.CTkButton(app, text="πŸ“‚ Select Images", command=select_files, font=("Arial", 16))

btn_select.pack(pady=10)


label_status = ctk.CTkLabel(app, text="No images selected", font=("Arial", 14), text_color="red")

label_status.pack(pady=5)


frame_size = ctk.CTkFrame(app)

frame_size.pack(pady=10)


entry_width = ctk.CTkEntry(frame_size, placeholder_text="Width (Optional)", width=120)

entry_width.grid(row=0, column=0, padx=10)

entry_height = ctk.CTkEntry(frame_size, placeholder_text="Height (Optional)", width=120)

entry_height.grid(row=0, column=1, padx=10)


dropdown_format = ctk.CTkComboBox(app, values=["JPG", "PNG", "WEBP"], font=("Arial", 14))

dropdown_format.pack(pady=10)


btn_process = ctk.CTkButton(app, text="πŸš€ Resize & Convert", command=process_images, fg_color="#29b6f6", hover_color="#0288d1", font=("Arial", 18))

btn_process.pack(pady=20)


app.mainloop()

Comments

Popular posts from this blog

πŸš€ Simple Login & Registration System in Python Tkinter πŸ“±

πŸš€ Create a Python Screen Recorder with Audio (Complete Code)

πŸ“‘ Fuzzu Packet Sniffer – Python GUI for Real-Time IP Monitoring | Tkinter + Scapy