@echo off
title PhotoResizer EXE Builder

echo ======================================
echo PhotoResizer v1.0 EXE Builder
echo ======================================
echo.

echo Checking Python...
python --version >nul 2>&1
if errorlevel 1 (
    echo [ERROR] Python is not installed or not in PATH.
    pause
    exit /b 1
)
echo Python OK

echo.
echo Checking PyInstaller...
pyinstaller --version >nul 2>&1
if errorlevel 1 (
    echo [ERROR] PyInstaller is not installed.
    echo.
    echo Install command:
    echo pip install pyinstaller
    pause
    exit /b 1
)
echo PyInstaller OK

echo.
echo Cleaning old build files...
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
if exist PhotoResizer.spec del PhotoResizer.spec

echo.
echo Building EXE...
pyinstaller ^
--onefile ^
--console ^
--name PhotoResizer ^
"%~dp0src\main.py"

if errorlevel 1 (
    echo.
    echo [ERROR] Build failed.
    pause
    exit /b 1
)

echo.
echo ======================================
echo Build Success
echo ======================================
echo EXE path:
echo %cd%\dist\PhotoResizer.exe
echo.

pause