Python Imaging Library/Getting PIL

From Wikibooks, open books for an open world
Jump to: navigation, search

Python is obviously a prerequisite for using PIL. The current version of PIL is 1.1.7, and this supports Python up to v.2.6. Support for Python 3 will be added soon.

PIL is available from PythonWare at this page. Source code can be built for any platform, and Windows binaries are available.

Installing PIL[edit]

Windows[edit]

To install on Windows machines, go to the page given above and download the appropriate binary executable for the version of Python that you have. Run this executable and follow the instructions given by the installer.

Linux[edit]

On Linux, you can either compile the source yourself, or install using your package manager. For Debian-based systems, apt-get can be used:

sudo apt-get install python-imaging

Mac OS X[edit]

To install on a Mac OS X system , visit http://pythonmac.org and download the relevant .dmg file and install as any other application.

Using PIL[edit]

Once install you need to import the PIL modules you want to use. Basic functions are found in the Image module, so the following will work:

import Image

You can then access functions as usual, e.g. Image.load(filename). Uses of the other modules available are given in the overview section, and these are imported in exactly the same way.