title: django - ZeroDivisionError when using thumbnail low-level API
body: <p>I implemented thumbnails for images that are displayed in an inline form, by creating my custom form (<a href="http://blog.glaucocustodio.com/2014/04/08/display-thumbnails-in-django-admin-with-sorl-thumbnail/" rel="nofollow noreferrer">like this</a>).</p>
  
  <p>However, in one case (that I noticed) so far, I get a ZeroDivisionError when trying to edit a project, and this is apparently caused by <a href="https://github.com/python-pillow/Pillow/blob/master/PIL/TiffImagePlugin.py#L482" rel="nofollow noreferrer">this line</a> in TiffImagePlugin, which is called by get_thumbnail. </p>
  
  <p>Here's the error traceback</p>
  
  <p><a href="https://i.stack.imgur.com/L0dmq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L0dmq.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/7QCtZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7QCtZ.png" alt="enter image description here"></a></p>
  
  <p>And here's my code (note I'm also using admin-sortable but I don't think that's related):</p>
  
  <pre><code>from django.contrib.admin.widgets import AdminFileWidget
  from django.utils.safestring import mark_safe
  from django.forms import ModelForm
  from sorl.thumbnail import get_thumbnail
  from models import Image
  
  class AdminImageWidget(AdminFileWidget):
      def render(self, name, value, attrs=None):
          output = []
          if value and getattr(value, "url", None):
            t = get_thumbnail(value,'80x80')
            output.append('&lt;img src="{}"&gt;'.format(t.url))
          output.append(super(AdminFileWidget, self).render(name, value, attrs))
          return mark_safe(u''.join(output))
  
  class ImageForm(ModelForm):
      class Meta:
          fields = '__all__'
          model = Image
          widgets = {
            'img': AdminImageWidget,
          }
  
  class ImageInline(SortableStackedInline):
      model = Image 
      extra = 3
      form  = ImageForm
  
  class ProjectAdmin(NonSortableParentAdmin):
      list_display = ('name', 'description')
      inlines = [ImageInline]
      list_filter = ('type',)
      search_fields = ('name', 'description')
  </code></pre>
  
  <p>Note this doesn't happen all the time, it only happens when trying to edit a <em>specific</em> project (and I'm assuming it might happen with others as well, but so far couldn't find more examples).</p>
  
  <p>Any ideas? Thanks in advanced!</p>