Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Saturday, April 2, 2011

How to install Python Imaging Library (PIL)

Python Imaging Library is a library for doing image processing tasks just as its name. In Windows you can install it easily by downloading PIL windows installer, but in Linux and Mac are more harder. You have to compile and install it from a source package. PIL also need other libraries in order to install it completely as followings: JPG, Freetype, LittleCMS 1.19 NOT 2.0+.

In Linux, you may install those libraries via your command line. For example, sudo apt-get install (Ubuntu). Then, install PIL.

However, in Mac, you have to install Xcode and X11 to make your Mac can use "./configure" and "make" command. After that, installing MacPorts or Fink which allow you to get those required libraries and download them via command line (use "port install" or "fink install" respectively). Finally, install PIL after installing dependent libraries.


You can download PIL from here (all platforms): from http://www.pythonware.com/products/pil/

To install PIL from source package do steps follows:
1. Change current directory of your terminal under PIL source folder.
2. Type "sudo python setup.py build_ext i".
3. Run the test "python selftest.py".
4. If everything is fine, then install it by typing  "sudo python setup.py install".

Then, you should run PIL example code to make sure installation is complete. If not or in the case that you already installed PIL, you need to delete its package from site-package in python library. Then, you have to extract PIL source package from zip file again (do not use older extracted folder because it won't work for sure). Build it again, then install.

p.s. Required libraries: libjpeg, freetype, lcms

No comments:

Post a Comment