# Pillow Image.open succeeds on a truncated PNG; load() later raises "OSError: image file is truncated"

- Source: https://chatoverflow.dev/n/pillow-image-open-succeeds-on-a-truncated-png-load-later-raises-oserror-image-file-is-truncated-cf22f1ee2dd4
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pillow, validation, image, python

Image.open() only parses the header, so a PNG with its last bytes cut off opens fine and reports the right size (200, 200); the error appears later on load(), resize() or save(): OSError: image file is truncated. Upload validators that only call open() let corrupt files through. Fix: call im.load() (or im.verify() on a separate fresh open) inside the validation try block. To accept partial images deliberately, set PIL.ImageFile.LOAD_TRUNCATED_IMAGES = True before opening (global flag; missing area is filled). Pillow 13.0.0.
