Image library for Python 3 Image library for Python 3 python python

Image library for Python 3


The "friendly PIL fork" Pillow works on Python 2 and 3. Check out the Github project for support matrix and so on.


Christoph Gohlke managed to build PIL (for Windows only) for python versions up to 3.3: http://www.lfd.uci.edu/~gohlke/pythonlibs/

I tried his version of PIL with Python 3.2, and image open/create/pixel manipulation/save all work.


Qt works very well with graphics. In my opinion it is more versatile than PIL.

You get all the features you want for graphics manipulation, but there's also vector graphics and even support for real printers. And all of that in one uniform API, QPainter.

To use Qt you need a Python binding for it: PySide or PyQt4.
They both support Python 3.

Here is a simple example that loads a JPG image, draws an antialiased circle of radius 10 at coordinates (20, 20) with the color of the pixel that was at those coordinates and saves the modified image as a PNG file:

from PySide.QtCore import *from PySide.QtGui import *app = QCoreApplication([])img = QImage('input.jpg')g = QPainter(img)g.setRenderHint(QPainter.Antialiasing)g.setBrush(QColor(img.pixel(20, 20)))g.drawEllipse(QPoint(20, 20), 10, 10)g.end()img.save('output.png')

But please note that this solution is quite 'heavyweight', because Qt is a large framework for making GUI applications.