Image troubleshooting


Problems with imaging libraries, image loading and image scaling.

How to test see if your Python Imaging set-up works

Example how to check if Python, Python Imaging Library (PIL) and libjpeg are correctly working together.

Get a sample image:


Start Python with Zope libraries in PYTHONPATH or Plone debug shell (latter):


# bin/instance debug  # <--- needs Plone site stopped first

Run the following on the interactive Python prompt started above:

import PIL
from PIL import Image
im ="JohnCarrollGilbertStuart.jpg")  # Open downloaded image
im.thumbnail((64, 64), Image.ANTIALIAS)  # See that PIL resize works"test.jpg")  # See that PIL JPEG writing works

No Python exceptions should be risen.

Images are not loading

Plone is not loading images or resized images are not available is usually caused by broken PIL installation: PIL used by the Python version that Plone is using does not have proper native libraries (libjpeg etcetera) available to perform imaging operations.

Solution: install the required native libraries for your operating system.

IOError when scaling images on Plone 4


Traceback (most recent call last):
  File "/srv/plone/xxx/plone-new/eggs/", line 73, in createScale
    imgdata, format = field.scale(data, width, height)
  File "/srv/plone/xxx/plone-new/eggs/Products.Archetypes-1.6.6-py2.6.egg/Products/Archetypes/", line 2501, in scale, format, quality=self.pil_quality)
  File "/srv/plone/python/python-2.6/lib/python2.6/site-packages/PIL-1.1.6-py2.6-linux-x86_64.egg/PIL/", line 1372, in save
  File "/srv/plone/python/python-2.6/lib/python2.6/site-packages/PIL-1.1.6-py2.6-linux-x86_64.egg/PIL/", line 207, in load
    raise IOError(error + " when reading image file")
IOError: decoding error when reading image file

This means that libjpeg setup is not working. See above to how to test your set-up.

Installing libraries on Ubuntu / Debian

This applies if you are using system Python to run Plone. Version may vary so apt-cache search and grep commands are your friends:

sudo apt-get install libpng12-dev  libjpeg62-dev python-imaging

Forcing libjpeg path

Try in buildout.cfg:

environment-vars =
        LD_LIBRARY_PATH /srv/plone/python/python-2.6/lib cannot open shared object file: No such file or directory

On Ubuntu you’ll get this error when you try:

import _imaging

Some tips