Skip to content
Home » IOError: image file truncated Python PIL

IOError: image file truncated Python PIL

To solve Python PIL “IOError: image file truncated” with big images error follow below methods.

ERROR LOG

 File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 220, in load
    raise IOError("image file is truncated (%d bytes not processed)" % len(b))
IOError: image file is truncated (57 bytes not processed)

How to solve Python PIL “IOError: image file truncated” with big images ?

Refer the given methods to solve the issue.

Solution:

PIL is reading in file blocks and anticipates that the blocks will be of a specific size. It turns out that you may tell PIL to be tolerant of truncated files (files missing from the block) by adjusting a setting.

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

Hope the above solution works.

Also read :

Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
Import Error: No module named django