When doing image manipulation with PIL in a Django app, you may see an error like decoder jpeg not available.
To fix this on os X, first you need to install libjpeg as follows:
brew update brew install libjpeg libpng
Next, try to reinstall PIL. Use the following command:
pip install --no-cache-dir PIL --allow-external PIL --allow-unverified PIL
That should be all. However, if you get an error saying cc command failed while installing freetype, then you will need to install freetype2 as follows:
brew install freetype2
Next you need to create a symbolic link to allow pip find freetype2 as follows:
ln -s /usr/local/Cellar/freetype/2.6.1/include/freetype2\ /usr/local/include/freetype
Note: 2.6.1 above is the version as at the time I ran the command. Replace it with the appropriate number for you.
Troubleshooting
If you do the above steps and still get the error, then uninstall the version installed via pip and build PIL from source. I had to do this once. Here’s code to see the decoders available
import _imaging dir(_imaging)
See if jpeg_decoder is among the properties