Python Image Library Error - Caught Ioerror While Rendering: Not Enough Data
I have created a website which is using the sorl-thumbnail to resize the images thats uploaded. Most of the images are getting resized without any issues but for few am getting the
Solution 1:
update
image._getexif
is claimed to be highly experimental. Refs sorl-thumbnail and issue #98, you could update the code to be
def_orientation(self, image):
try:
exif = image._getexif()
except (AttributeError, IOError):
exif = None
It's caused by PIL's attempt to load a corrupted or possibly unsupported TIFF file.
Normally when you use forms.ImageField
, Django would check the correctness of uploaded images.
Thus you need to:
- ensure that you're using
forms.ImageField
, which is default formodels.ImageField
, to deal w/ uploading in your view check the uploaded image by
from PIL import Image Image.open(path).load()
- use toolkit that processing TIFF to open the image and, if you can open it , save it to Jpeg or Png and update the field of the model instance to point to the new file.
Also you could limit user to upload normal formats such as jpeg/png/gif instead of TIFF
Post a Comment for "Python Image Library Error - Caught Ioerror While Rendering: Not Enough Data"