Porting

Porting existing PIL-based code to Pillow

Pillow is a functional drop-in replacement for the Python Imaging Library. Torun your existing PIL-compatible code with Pillow, it needs to be modified toimport the Image module from the PIL namespace instead of theglobal namespace. Change this:

  1. import Image

to this:

  1. from PIL import Image

The _imaging module has been moved. You can now import it like this:

  1. from PIL.Image import core as _imaging

The image plugin loading mechanism has changed. Pillow no longerautomatically imports any file in the Python path with a name endingin ImagePlugin.py. You will need to import your image pluginmanually.

Pillow will raise an exception if the core extension can’t be loadedfor any reason, including a version mismatch between the Python andextension code. Previously PIL allowed Python only code to run if thecore extension was not available.