What I hate about PIL and Image in Python

19 October 2009   6 comments   Python

Mind that age!

This blog post is 12 years old! Most likely, its content is outdated. Especially if it's technical.

One really annoying thing about PIL is that it's importable as Image and PIL. It leads me and other newbies to think if it's different. I don't want choices:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> import Image
>>> ?

When PIL/Image is put into standard lib, can we call the module: imaging?



At least on my machine these two are not the same:

In [14]: import PIL

In [15]: PIL.__file__
Out[15]: '/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/__init__.pyc'

In [16]: import Image

In [17]: Image.__file__
Out[17]: '/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/Image.pyc'

In [18]: dir(PIL)
Out[18]: ['__builtins__', '__doc__', '__file__', '__name__', '__path__']

In [19]: dir(Image)

Tomasz Elendt

I believe this is the real problem:

>>> from PIL import Image as A
>>> import Image as B
>>> B.__file__ == A.__file__

paulo roberto

zen of python

"There should be one-- and preferably only one --obvious way to do it"


The PIL API is far too horrible to put in the standard library - are they really considering this? Just because it's the only library available for this sort of thing doesn't mean it should end up included as standard.

Peter Bengtsson

Fair points. I'm not saying they are but IF they do I have an opinion about the naming.

Whatever it is, it better be consistent.


What about PythonMagick, using it for years despite the bugs in combination with PIL and numpy. The buglist gains speed according to my inbox so there is slight hope on better image processing routines in Python.

Your email will never ever be published

Related posts