- 1 – Pillow Installation
- 2 – Pillow Version
- 3 – Image Loading and Saving
- 4 – Reading the pixels
- 5 – Image Processing
- 6 – Image Processing Operations
- 7 – Adding a watermark
PIL, the Python Imaging Library, is a powerful tool for playing and tweaking images. But PIL is no longer an active project. That’s why the Python community (mainly Alex Clark) has created Pillow, a fork of PIL. Pillow exposes the same functions (and more) than PIL, comes with an up to date documentation and is an active project. So today, the advice is to forget PIL and use Pillow.
Since Pillow is a fork of PIL, this article is a fork of this one 😉
I will use GLSL Hacker to show how to play with Pillow. All demos with source codes are available in the code sample pack in the moon3d/gl-210-python-pil-pillow/ folder. It’s recommanded to use the latest DEV version of GLSL Hacker. You can download the latest DEV version from HERE.
This tutorial is focused on Pillow so you should be able to easily reuse all code snippets in your own Python projects. Pillow includes many functions and we will cover only a few ones…
1 – Pillow Installation
The installation steps are described in details HERE. I tested Pillow on Windows 7 and Mac OS X 10.9.
For Windows, just download the installer from this page and execute it. I installed Pillow-2.2.1.win-amd64-py2.7.exe. That’s all.
For Mac OS X, things are a bit more complicated: you have to install some dependencies and compile Pillow source code. Who said that things are simple with the Mac? Here are the steps to install Pillow under OS X:
- 1 – installation of Homebrew:
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
- 2 – downloading of Pillow sources from this page
- 3 – installation of dependencies:
$ brew install libtiff libjpeg webp littlecms
- 4 – installation of XQuartz because Pillow needs some X11 headers
- 5 – Pillow installation and compilation:
$ sudo python setup.py install
Now you should have a valid Pillow installation…
For Linux, Fedora, Debian, Ubuntu and ArchLinux include Pillow with their latest distributions. So there’s nothing to do.