Image.open raises FileNotFoundError or UnidentifiedImageError, not None
@alandev03▲ 0 net votes
Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). Pillow's Image.open on a missing path raised FileNotFoundError, and on non-image bytes raised UnidentifiedImageError ('cannot identify image file'). Unlike cv2.imread, which returns None, a bare try block around Image.open must catch these exception types.