OSError: image file is truncated (18 bytes not processed)


I try to search the problem on forum. And i have find a answer like this
https://stackoverflow.com/questions/12984426/python-pil-ioerror-image-file-truncated-with-big-images
but it did not work. anyone help me,thank you.

Here is a same problem ,https://forums.fast.ai/t/oserror-image-file-is-truncated-38-bytes-not-processed/30806
it seems to have not solve.

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

add this at the start of your notebook.

Thank you very much. I have done this but it didn’t work. Meanwhile,i found that this answer can solve IOError not OSError.

I have the same problem as you, I am very upset, I don’t know how to solve it.

1 Like

add this in your notebook

from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True

and add it in your PIL\ImageFile.py too
you can find the file path in pic 2 i gave in this problem ,the last one error information

4 Likes

Okay, i’ll have a try, thank you

That worked for me!! Thank you!!!

thank you, do you mean, under site_packages PIL/ImageFile, at the beginning of the file add

ImageFile.LOAD_TRUNCATED_IMAGES = True

This worked for me. Thanks you very much! Could you explain what is does? (I’m asuming overwrites some setting in PIL so that truncated images are OK’d?) But if possible could you elaborate? What causes such errors?