from pathlib import Path
from typing import Iterable

IMAGE_EXTS = {".jpg", ".jpeg", ".png", ".tif", ".tiff", ".webp", ".bmp"}
PDF_EXTS = {".pdf"}

def iter_files(root: str | Path) -> Iterable[Path]:
    root = Path(root)
    for p in root.rglob("*"):
        if p.is_file() and p.suffix.lower() in IMAGE_EXTS.union(PDF_EXTS):
            yield p

def ensure_dir(p: str | Path):
    Path(p).parent.mkdir(parents=True, exist_ok=True)
