Monday, April 27, 2009

Building the Python Imaging Library (PIL) for iPhone/iPod Touch

As my last post hints at I have started experimenting with building PIL for my iPod Touch. Doing so is non-trivial and I have therefore decided to write a small tutorial here, so that others may be spared of wasting their time on this project ;-)

What I did was to compile the thing directly on the iPod, and to do that I went through the following steps:
  1. Jailbreak: I used QuickPWN 2.2.5 under Windows (it did not work on my Mac for some reason) and that was quite easy.
  2. Install SSH on the iPod using Cydia (there is an entry in the main menu showing you how to do that).
  3. SSH in to your iPod as the root user with password "alpine".
  4. Install Python, the gcc compiler, the code signing tool, and make by issuing this command: apt-get install python iphone-gcc ldid make (alternatively you could install it using Cydia it you like).
  5. Download the SDK headers, you may find them along with a description of how to use them here.
  6. [Optional] Download the libjpeg source if you want jpeg support. Untar the source bundle, enter the directory containing the source and issue the following commands:
    export C_INCLUDE_PATH=/var/include/
    ./configure --prefix=/usr/
    make
    make install
    make install-lib
  7. Download the PIL source and unpack it.
  8. Enter the source directory and issue the following commands:
    python setup.py build
    python setup.py install
    ldid -S /usr/lib/python2.5/site-packages/PIL/*.dylib

After going through all of these steps I ended up with a working PIL library on my iPod. Oh, and thanks to Renaud Blanch for pointing out to me that I needed to sign the dynamic libraries for them to work.

No comments:

Post a Comment