Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPG decoder not included in requirements.txt #110

Closed
premasagar opened this issue Apr 7, 2011 · 5 comments
Closed

JPG decoder not included in requirements.txt #110

premasagar opened this issue Apr 7, 2011 · 5 comments
Assignees
Labels
Milestone

Comments

@premasagar
Copy link
Member

On uploading a JPG to my user profile, the photo was successfully uploaded, but viewing the image gave a 500 error. Presumably, the requirements.txt should include a JPG decoder.

The error:

IOError at /thumb/16x16/images/users/prem_photo.jpg
decoder jpeg not available
Request Method: GET
Request URL:    http://localhost:8000/thumb/16x16/images/users/prem_photo.jpg?crop
Django Version: 1.2.5
Exception Type: IOError
Exception Value:    
decoder jpeg not available
Exception Location: /usr/local/lib/python2.6/dist-packages/PIL/Image.py in _getdecoder, line 385
Python Executable:  /usr/bin/python
Python Version: 2.6.6
Python Path:    ['/home/premasagar/projects/tasket/web', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '../server', '../server']
Server time:    Thu, 7 Apr 2011 12:12:03 +0100

Environment:

Request Method: GET
Request URL: http://localhost:8000/thumb/16x16/images/users/prem_photo.jpg?crop
Django Version: 1.2.5
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'tasks',
 'frontend',
 'sorl.thumbnail',
 'indexer',
 'paging',
 'sentry',
 'sentry.client']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'utils.middleware.CORSAuthorizationMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'utils.middleware.CORSMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "../server/tasks/views.py" in thumbs
  381.     im = get_thumbnail(im_obj, size, quality=99, crop=crop)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/shortcuts.py" in get_thumbnail
  8.     return default.backend.get_thumbnail(file_, geometry_string, **options)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/base.py" in get_thumbnail
  48.                                    thumbnail)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/base.py" in _create_thumbnail
  73.         image = default.engine.create(source_image, geometry, options)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/engines/base.py" in create
  14.         image = self.colorspace(image, geometry, options)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/engines/base.py" in colorspace
  24.         return self._colorspace(image, colorspace)
File "/usr/local/lib/python2.6/dist-packages/sorl/thumbnail/engines/pil_engine.py" in _colorspace
  43.             return image.convert('RGB')
File "/usr/local/lib/python2.6/dist-packages/PIL/Image.py" in convert
  679.         self.load()
File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py" in load
  189.                 d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/usr/local/lib/python2.6/dist-packages/PIL/Image.py" in _getdecoder
  385.         raise IOError("decoder %s not available" % decoder_name)

Exception Type: IOError at /thumb/16x16/images/users/prem_photo.jpg
Exception Value: decoder jpeg not available
@premasagar
Copy link
Member Author

Out of interest, I tried uploading a GIF and again I got:

IOError at /thumb/16x16/images/users/Sunflower_as_gif_small.gif
encoder jpeg not available
Request Method: GET
Request URL:    http://localhost:8000/thumb/16x16/images/users/Sunflower_as_gif_small.gif?crop
Django Version: 1.2.5
Exception Type: IOError
Exception Value:    
encoder jpeg not available
Exception Location: /usr/local/lib/python2.6/dist-packages/PIL/Image.py in _getencoder, line 401
Python Executable:  /usr/bin/python
Python Version: 2.6.6
Python Path:    ['/home/premasagar/projects/tasket/web', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '../server', '../server']
Server time:    Thu, 7 Apr 2011 12:16:16 +0100

I'm not sure why the error still mentions a JPG decoder. I guess we should let people upload GIFs, but anyway, if a user uploads a file that is not a supported file type, or if anything goes wrong with the image processing, then some kind of controlled error response (in JSON) should be there. 401 Bad Request? Probably a better code out there.

@symroe
Copy link
Contributor

symroe commented Apr 7, 2011

I've never seen this before. A google returns this link: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm

It's an install specific thing, and I'm not sure I can control it in requirements.txt...

@symroe
Copy link
Contributor

symroe commented Apr 7, 2011

Is libjpeg installed?

@premasagar
Copy link
Member Author

I already had libjpeg62 installed (there is no "libjpeg" avail to apt-get). I just installed libjpeg62-dev and still no change.

This post seems relevant:
http://www.eddiewelker.com/2010/03/31/installing-pil-virtualenv-ubuntu/

@ghost ghost assigned symroe and premasagar Apr 10, 2011
@premasagar
Copy link
Member Author

Reinstalling PIL according to the explicit sequence in http://www.eddiewelker.com/2010/03/31/installing-pil-virtualenv-ubuntu/ solved this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants