INNER CODE UNIT · Python

valid_image_file

ChenShuo2004/cs-board · webapp/server.py:551

def valid_image_file(path: Path) -> bool:
    if not path.exists() or path.stat().st_size < 1024:
        return False
    try:
        from PIL import Image
        with Image.open(path) as image:
            image.verify()
        return True
    except Exception:
        return False


def valid_media_file(path: Path) -> bool:
    if not path.exists() or path.stat().st_size < 1024:
        return False
    try:
        return probe_duration(path) > 0.1
    except Exception:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…