#!/usr/bin/env python3
"""
Show large thumbnails directly from the test images
"""

import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk
import os
from pathlib import Path

# Suppress TensorFlow warnings
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

def show_large_thumbnails():
    root = tk.Tk()
    root.title("Large Thumbnails Demo")
    root.geometry("1600x1000")
    
    frame = ttk.Frame(root, padding="20")
    frame.pack(fill=tk.BOTH, expand=True)
    
    # Get test images
    test_folder = Path("demo_photos/testdeepface/")
    if not test_folder.exists():
        ttk.Label(frame, text="Test folder not found: demo_photos/testdeepface/", 
                 font=("Arial", 16, "bold"), foreground="red").pack(pady=20)
        root.mainloop()
        return
    
    image_files = list(test_folder.glob("*.jpg"))
    
    if not image_files:
        ttk.Label(frame, text="No images found in test folder", 
                 font=("Arial", 16, "bold"), foreground="red").pack(pady=20)
        root.mainloop()
        return
    
    # Show first few images with large thumbnails
    ttk.Label(frame, text="Large Thumbnails Demo (400x400 pixels)", 
             font=("Arial", 18, "bold")).pack(pady=10)
    
    for i, img_path in enumerate(image_files[:4]):  # Show first 4 images
        try:
            # Load and resize image
            image = Image.open(img_path)
            image.thumbnail((400, 400), Image.Resampling.LANCZOS)
            photo = ImageTk.PhotoImage(image)
            
            # Create frame for this image
            img_frame = ttk.Frame(frame)
            img_frame.pack(pady=10)
            
            # Image label
            img_label = ttk.Label(img_frame, image=photo)
            img_label.image = photo  # Keep a reference
            img_label.pack()
            
            # Text label
            text_label = ttk.Label(img_frame, text=f"{img_path.name} (400x400)", 
                                 font=("Arial", 12, "bold"))
            text_label.pack()
            
        except Exception as e:
            ttk.Label(frame, text=f"Error loading {img_path.name}: {e}", 
                     font=("Arial", 12), foreground="red").pack()
    
    # Add instruction
    instruction = ttk.Label(frame, text="These are 400x400 pixel thumbnails - the same size the GUI will use!", 
                           font=("Arial", 14, "bold"), foreground="green")
    instruction.pack(pady=20)
    
    root.mainloop()

if __name__ == "__main__":
    show_large_thumbnails()
