florianletsch
florianletsch

Reputation: 465

PIL doesn't recognize jpeg library under Mac OS

Scripts like that:

from PIL import Image, ImageOps
img = Image.open('1.JPG')
thumb = ImageOps.fit(img, (200,200) , Image.ANTIALIAS, (0.5, 0.5))

cause this IOError:

Traceback (most recent call last):
  (...)
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available

How do I get jpeg support for my PIL? That issue seems to be well known but the existing threads don't solve it for me. I use brew and pip for my python packages and have already tried the following:

How do I get jpeg support for my PIL installation? Any ideas?

Upvotes: 5

Views: 3859

Answers (3)

Belrog
Belrog

Reputation: 960

For non OSX people landing here, I found linking to the 64 bit libraries on my 64 bit Ubuntu system to fix the compile issue.

Upvotes: 0

Dolph
Dolph

Reputation: 50690

I ran into a similar problem on Ubuntu 12.04 64-bit and solved it by symlinking the libraries PIL was looking for into /usr/lib (where it was actually looking for them):

# symlink image libraries so PIL can find them
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
# etc for any other libraries

Upvotes: 0

florianletsch
florianletsch

Reputation: 465

I don't understand why, but reinstalling PIL fixed the issue:

sudo pip uninstall pil
sudo pip install pil

Upvotes: 8

Related Questions