import os
from pathlib import Path
from typing import List

from config import get_input_path


def scan_images(config: dict) -> List[Path]:
    source_path = get_input_path(config)
    
    if not source_path.exists():
        return []
    
    supported_extensions = config.get("supported_extensions", [".jpg", ".jpeg", ".png", ".webp"])
    supported_extensions = [ext.lower() for ext in supported_extensions]
    
    image_files = []
    
    for root, dirs, files in os.walk(source_path):
        for file in files:
            file_lower = file.lower()
            if any(file_lower.endswith(ext) for ext in supported_extensions):
                image_files.append(Path(root) / file)
    
    return sorted(image_files)