What I hate about PIL and Image in Python

19 October 2009   6 comments   Python

Mind That Age!

This blog post is 9 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

Messed up columns in Django Admin 16 October 2009
What makes my website slow? DNS 23 October 2009
Related by Keyword:
ImageMagick conversion comparison 09 December 2006
Dynamic image replacement technique 24 February 2006
Related by Text:
Be very careful with your add_header in Nginx! You might make your site insecure 11 February 2018
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
I'm Prolog 01 May 2007