Closed swaroopsv closed 10 years ago
As a fast fix for me I patched "sorl-thumbnail / sorl / thumbnail / engines / pil_engine.py" from:
def _orientation(self, image):
try:
exif = image._getexif()
except AttributeError:
exif = None
if exif:
to
def _orientation(self, image):
try:
exif = image._getexif()
except (AttributeError, IOError):
exif = None
if exif:
This is fix in the current master branch. Thanks
Look at https://github.com/mariocesar/sorl-thumbnail/blob/master/sorl/thumbnail/engines/pil_engine.py#L65
Am getting a wired error for jpeg images which got TIFF embedded. Following are the stacktrace
Caught IOError while rendering: not enough data Request Method: GET Request URL: http://localhost:8000/user/nash22/photographs/ Django Version: 1.3.1 Exception Type: TemplateSyntaxError Exception Value:
Caught IOError while rendering: not enough data Exception Location: /usr/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py in load, line 382 Python Executable: /usr/local/bin/python Python Version: 2.7.1
Traceback (most recent call last):
File "/lib/python2.7/django/core/handlers/base.py", line 111, in get_response response = callback(request, _callback_args, *_callback_kwargs)
File "/home/swaroop/project/apps/photography/views.py", line 702, in showPhoto context_instance=RequestContext(request))
File "/lib/python2.7/django/shortcuts/init.py", line 20, in render_to_response return HttpResponse(loader.render_to_string(_args, *_kwargs), **httpresponse_kwargs)
File "/lib/python2.7/django/template/loader.py", line 188, in render_to_string return t.render(context_instance)
File "/lib/python2.7/django/template/base.py", line 123, in render return self._render(context)
File "/lib/python2.7/django/template/base.py", line 117, in _render return self.nodelist.render(context)
File "/lib/python2.7/django/template/base.py", line 744, in render bits.append(self.render_node(node, context))
File "/lib/python2.7/django/template/base.py", line 757, in render_node return node.render(context)
File "/lib/python2.7/django/template/loader_tags.py", line 127, in render return compiled_parent._render(context)
File "/lib/python2.7/django/template/base.py", line 117, in _render return self.nodelist.render(context)
File "/lib/python2.7/django/template/base.py", line 744, in render bits.append(self.render_node(node, context))
File "/lib/python2.7/django/template/base.py", line 757, in render_node return node.render(context)
File "/lib/python2.7/django/template/loader_tags.py", line 64, in render result = block.nodelist.render(context)
File "/lib/python2.7/django/template/base.py", line 744, in render bits.append(self.render_node(node, context))
File "/lib/python2.7/django/template/base.py", line 757, in render_node return node.render(context)
File "/lib/python2.7/sorl/thumbnail/templatetags/thumbnail.py", line 45, in render return self._render(context)
File "/lib/python2.7/sorl/thumbnail/templatetags/thumbnail.py", line 97, in render file, geometry, **options
File "/lib/python2.7/sorl/thumbnail/base.py", line 61, in get_thumbnail thumbnail)
File "/lib/python2.7/sorl/thumbnail/base.py", line 86, in _create_thumbnail image = default.engine.create(source_image, geometry, options)
File "/lib/python2.7/sorl/thumbnail/engines/base.py", line 15, in create image = self.orientation(image, geometry, options)
File "/lib/python2.7/sorl/thumbnail/engines/base.py", line 26, in orientation return self._orientation(image)
File "/lib/python2.7/sorl/thumbnail/engines/pil_engine.py", line 29, in _orientation exif = image._getexif()
File "/usr/local/lib/python2.7/site-packages/PIL/JpegImagePlugin.py", line 381, in _getexif info.load(file)
File "/usr/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py", line 382, in load raise IOError, "not enough data"
IOError: not enough data
Is this a bug with the code in TiffImagePlugin.py?