cannot identify image file <_io.BytesIO object a> site:stackoverflow.com
import PIL
from pathlib import Path
from PIL import UnidentifiedImageError
path = Path("INSERT PATH HERE").rglob("*.jpeg")
for img_p in path:
try:
img = PIL.Image.open(img_p)
except PIL.UnidentifiedImageError:
print(img_p)