tags:

views:

335

answers:

2

I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux distributions.)

If there is none, what is the most common lib?

Many search results hint me to Python Imaging Library. If this is some well known Python-lib for reading images, why isn't it included in Python?

+11  A: 

No, there are no modules in the standard library for reading/writing/processing images directly. But the most common library might be PIL (Python Imaging Library). Many projects are not included in the standard library because they are 1) totally optional and 2) cannot be maintained by the few Python core developers.

AndiDog
+1 for suggesting PIL
batbrat
Python Imaging Library rocks.
Mark
Well I don't really see why it has regexp, unzip, http, imap, ftp and all that stuff (don't get me wrong: I am really happy that it is all there) but not simple image loading functions. But ok, thanks for those information!
Albert
Lennart Regebro already pointed it out: Python's standard library contains too much stuff that 1) is not used, 2) doesn't belong in the standard library or 3) is of questionnable quality. Hopefully there will be more cleanup going on in Python 4.x ...
AndiDog
+1  A: 

THe suggested PIL does not support interlaced PNGs. It can be quite anoying when dealing with lots of PNGs from different origins. It is possible to open them, but can only read headerinformation from them, all other operations fail.

So, what other suggestion do you have? What is the best lib?
Albert
Well, I haven't used any other graphics libraries besides PIL in python, but [pypng](http://code.google.com/p/pypng/) claims to support all types of PNG files. Its pure python so it may not be the fastest way to open PNGs and also has a pretty limited API. I guess it could be used to load interlaced PNGs into PIL.You can check if an PNG is interlaced with in the "info" dict of the Image classBesides that there are also Python bindings for [ImageMagick](http://www.imagemagick.org/script/api.php).