six-pack / Axis-Mundi

A secure, resilient, distributed and open communication platform.
59 stars 21 forks source link

IOError: decoder jpeg not available #11

Closed dreboli closed 9 years ago

dreboli commented 9 years ago

Upon uploading a .jpg

127.0.0.1 - - [] "POST /listings/new/ HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_login.py", line 758, in decorated_view
    return func(*args, **kwargs)
  File "client.py", line 265, in new_listing
    image = str(encode_image(listing_image_file.read(),(128,128))) # TODO - maintain aspect ratio
  File "/utilities.py", line 43, in encode_image
    im.thumbnail(size, Image.ANTIALIAS)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1559, in thumbnail
    self.load()
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 189, in load
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 385, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
dreboli commented 9 years ago

Similar with this png : http://logos.wikia.com/wiki/File:Logo_rolling_stones.png

IOError: decoder zip not available

six-pack commented 9 years ago

This looks like it's system specific and is going to be down to whether libjpeg-dev or other relevant image libraries were present on the system when PIL (or pillow) was installed and compiled.

Could you try installing jpg libraries to the system using apt-get install libjpeg-dev

and then reinstall PIL or pillow with pip install -I pil or pip install -I pillow

I guess we need to be making sure those dependencies are present on the system before installing PIL or pillow

Let me know if the above fixes your jpg issue

dreboli commented 9 years ago

I had PIL installed (an error msg suggested to install this package when image upload failed) Version is 1.1.7.

pip freeze | grep PIL
Warning: cannot find svn location for distribute==0.6.24dev-r0
PIL==1.1.7

I tried apt-get install libjpeg-dev but still had the same problem, had to install pillow too to solve the issue.

six-pack commented 9 years ago

Pillow compiles itself when you install it. It compiles in support for various things (like png, jpg, zip support) depending on what system libs are installed at that time. If you try to install pillow without the libraries already installed then Pillow will be built without them.

I should probably switch wholesale to Pillow away from PIL anyway

dreboli commented 9 years ago

Ah I see now, thanks. I should mention that I'm not too familiar with coding or linux in general and my english is not too good either so these should be taken into account when reading my comments.

six-pack commented 9 years ago

Hey man, you're comments are crystal clear and really appreciated so thankyou!

I'm going to reopen this though becasue it needs to be fixed (it really is a bug)

six-pack commented 9 years ago

Reopening - fix by having installer make sure image libraries are present before installing/reinstalling Pillow

Ricardo-Spanish commented 9 years ago

libjpeg and zlib1 are now stated in the pre-reqs - as long as these are present before PIP/pillow is installed (assuming PIP is used) then this problem should not be present.

Binaries are now built on systems with these requirements already installed.

Closing as fixed