Pillow/PIL exception: Tile cannot extend outside image

Bug #1271919 reported by Paul Everitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KARL3
Fix Released
Medium
Chris McDonough

Bug Description

We had ten or so of these exceptions yesterday, all for trying to render the same image. I think the image is some KARL/PIL auto-generated thumbnail. Perhaps the original image is smaller than the coordinates we are trying to thumbnail down to

SystemError: tile cannot extend outside image
Exception when processing https://karl.soros.org/communities/african-advocacy/blog/fw-invitation-conectas-b4-xi-international-human-rights-colloquium/attachments/image007.jpg/thumb/85x85.jpg
Referer: https://karl.soros.org/communities/justice-initiative-advocacy-group/wiki/front_page/edit.html

Traceback (most recent call last):
  File "/srv/osfkarl/production/35/eggs/pyramid-1.2.1-py2.6.egg/pyramid/tweens.py", line 17, in excview_tween
    response = handler(request)
  File "/srv/osfkarl/production/35/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 107, in tm_tween
    return response
  File "/srv/osfkarl/production/35/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 75, in __exit__
    return self._retry_or_raise(t, v, tb)
  File "/srv/osfkarl/production/35/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 60, in _retry_or_raise
    reraise(t, v, tb) # otherwise reraise the exception
  File "/srv/osfkarl/production/35/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 100, in tm_tween
    response = handler(request)
  File "/srv/osfkarl/production/35/eggs/pyramid-1.2.1-py2.6.egg/pyramid/router.py", line 153, in handle_request
    response = view_callable(context, request)
  File "/srv/osfkarl/production/35/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 186, in _secured_view
    return view(context, request)
  File "/srv/osfkarl/production/35/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 319, in viewresult_to_response
    result = view(context, request)
  File "/srv/osfkarl/production/35/eggs/karl-3.119-py2.6.egg/karl/content/views/files.py", line 690, in thumbnail_view
    thumb = context.thumbnail(tuple(size))
  File "/srv/osfkarl/production/35/eggs/karl-3.119-py2.6.egg/karl/content/models/files.py", line 134, in thumbnail
    self._thumbs[key] = thumbnail = Thumbnail(image, size)
  File "/srv/osfkarl/production/35/eggs/karl-3.119-py2.6.egg/karl/content/models/files.py", line 212, in __init__
    thumb_img.save(img_buf, 'JPEG', quality=90)
  File "/srv/osfkarl/production/35/eggs/Pillow-1.7.5-py2.6-linux-i686.egg/PIL/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/srv/osfkarl/production/35/eggs/Pillow-1.7.5-py2.6-linux-i686.egg/PIL/JpegImagePlugin.py", line 471, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/srv/osfkarl/production/35/eggs/Pillow-1.7.5-py2.6-linux-i686.egg/PIL/ImageFile.py", line 484, in _save
    e.setimage(im.im, b)
SystemError: tile cannot extend outside image

Revision history for this message
Chris McDonough (chrism-plope) wrote :

I did not validate that generating a thumbnail smaller than the original image was actually the problem in the above object, but I did add some guard code for this case:

https://github.com/karlproject/karl/commit/30c5a70978aec822af8f7b1faa4541c7432f86ef

Revision history for this message
Paul Everitt (paul-agendaless) wrote :

I think that's a reasonable remediation. I will mark this as Fix Committed. Chris, should I do the staging/production release? Or should you and I spend some time so that you can do it?

Changed in karl3:
status: New → Fix Committed
Revision history for this message
Paul Everitt (paul-agendaless) wrote :

Chris, did this ever get deployed?

Changed in karl3:
milestone: m133 → m134
Tres Seaver (tseaver)
Changed in karl3:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.