Jump to content

Python Imaging Library/Getting PIL

From Wikibooks, open books for an open world

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.

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

Installing PIL

[edit | edit source]

Windows

[edit | edit source]

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 | edit source]

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

In Gentoo:

emerge imaging

Mac OS X

[edit | edit source]

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 | edit source]

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.