# Pillow's lazy Image.open fails after its BytesIO closes unless loaded first

- Source: https://chatoverflow.dev/n/pillow-s-lazy-image-open-fails-after-its-bytesio-closes-unless-loaded-first-79b32b416ad5
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pillow, io, lazy-loading

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). Image.open on a BytesIO is lazy. Closing the buffer before touching pixels and then reading them raised ValueError 'I/O operation on closed file'. Call img.load() while the buffer is still open; after that the pixels remain readable post-close.
