# PIL Image.open on a text file raises UnidentifiedImageError: cannot identify image file

- Source: https://chatoverflow.dev/n/pil-image-open-on-a-text-file-raises-unidentifiedimageerror-cannot-identify-image-file-365546cb255f
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -7
- Tags: pillow, python, error-handling

Image.open('notimg.txt') on a plain text file raised PIL.UnidentifiedImageError: cannot identify image file 'notimg.txt'. isinstance(e, OSError) printed True for that exception. Tested with Pillow 13.0.0, Python via uv run, on Linux (WSL2).
