Bonjour,

J'ai besoin de la librairie "PIL (Python Imaging Library).

L'installation par YUM ne me convient pas car elle ne contient pas le support des images.
J'ai donc du me tourner vers une installation hors yum.
J'ai telecharge PIL sur http://www.pythonware.com/products/pil/index.htm

et j'ai pris la dernière version : Python Imaging Library 1.1.7 Source Kit (all platforms) (November 15, 2009).

J'ai trouve sur http://wiki.mediatemple.net/w/CentOS_5.5_%28VE%29_Server_Build_-_Django_1.3,_Python_2.7

J'ai aussi installe les paquets manquants:

# yum install zlib zlib-devel
# yum install libjpeg libjpeg-devel
# yum install freetype freetype-devel
[root@localhost Imaging-1.1.7]# yum list zlib zlib-devel libjpeg libjpeg-devel freetype freetype-devel
Modules complémentaires chargés : langpacks, presto, refresh-packagekit
Paquets installés
freetype.x86_64                                                                                2.4.4-7.fc15                                                                           @updates
freetype-devel.x86_64                                                                          2.4.4-7.fc15                                                                           @updates
zlib.i686                                                                                      1.2.5-6.fc15                                                                           @updates
zlib.x86_64                                                                                    1.2.5-6.fc15                                                                           @updates
zlib-devel.x86_64                                                                              1.2.5-6.fc15                                                                           @updates
Lorsque j'execute l'installation dans python : python setup.py build_ext -i

il me dit
[root@localhost Imaging-1.1.7]# python setup.py build_ext -i
running build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.1 (r271:86832, Apr 12 2011, 16:15:16)
              [GCC 4.6.0 20110331 (Red Hat 4.6.0-2)]
--------------------------------------------------------------------
*** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

To check the build, run the selftest.py script.
mais lorsque je veux tester avec selftest, voici ce qu'il me dit
[root@localhost Imaging-1.1.7]# python selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY 
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
*** JPEG support not installed
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
*****************************************************************
Failure in example:
try:
 _info(Image.open(os.path.join(ROOT, "Images/lena.jpg")))
except IOError, v:
 print v
from line #24 of selftest.testimage
Expected: ('JPEG', 'RGB', (128, 128))
Got: decoder jpeg not available
1 items had failures:
   1 of  57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
Donc je ne peux pas l'installer puisque le test n'est pas bon.

Quelqu'un a-t'il une idée pourquoi, le système me dit qu'il est bon au build et pas au test !
et si possible comment résoudre le problème.

Merci
Bonjour,
treize59 wrote: J'ai besoin de la librairie "PIL (Python Imaging Library).

L'installation par YUM ne me convient pas car elle ne contient pas le support des images.
Ça semble suffisamment étonnant, lu ainsi, pour que je te demande de développer ce point.
As-tu un rapport de bogue que tu as soumis concernant le paquet python-imaging sur Bugzilla ?
Pikachu_2014 wrote:Bonjour,
treize59 wrote: J'ai besoin de la librairie "PIL (Python Imaging Library).

L'installation par YUM ne me convient pas car elle ne contient pas le support des images.
Ça semble suffisamment étonnant, lu ainsi, pour que je te demande de développer ce point.
Non seulement c'est étonnant, mais pour l'avoir utilisé il y a peu, je ne suis pas d'accord.
Bonjour,

J'ai compris sur le site que je citais precedemment

"At this point, if you install PIL without first satisfying dependencies, PIL will be built without libjpeg and zlib (png support). The output of python setup.py install would be:"

Je vais essayer de remettre pil par yum.
Et pourquoi pas prendre python 2.7 par yum aussi ? De mémoire il est disponible pour EL5.
C'est déjà python 2.7 (installé par yum)

[manufd@localhost OOo]$ python --version
Python 2.7.1

Pour tester PIL, j'utilise ça
[root@localhost OOo]# cat PilTest.py
from PIL import Image
i = Image.open("/usr/local/lib64/python/Imaging-1.1.7/Images/lena.jpg")
i.verify()
i.load()
[root@localhost OOo]# python PilTest.py
Traceback (most recent call last):
  File "PilTest.py", line 4, in <module>
    i.load()
  File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 170, in load
    read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'
[root@localhost OOo]# 
Pourquoi travailler en root ?

Sinon ton fichier '/usr/local/lib64/python/Imaging-1.1.7/Images/lena.jpg' il existe ?
Bonjour,

Désolé pour le retard, oui, il existe.

[manufd@localhost Imaging-1.1.7]$ ls -l /usr/local/lib64/python/Imaging-1.1.7/Images/lena.jpg
-rw-r--r--. 1 root root 4788 1 nov. 2009 /usr/local/lib64/python/Imaging-1.1.7/Images/lena.jpg

Je vais refaire la même manip sans root.
python PilTest.py
Traceback (most recent call last):
  File "PilTest.py", line 4, in <module>
    i.load()
  File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 170, in load
    read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'
[manufd@localhost OOo]$ python clean
python: can't open file 'clean': [Errno 2] No such file or directory
Je viens de faire un petit tour sur la documentation de PIL.
Donc, d'après ce que j'ai compris, au sujet de ton fichier PilTest.py :
- i.verify() : nécessite de réouvrir l'image avant d'autres opérations ;
- i.load() : retourne un objet correspondant aux pixels de l'image (donc je vois pas trop l'intérêt du test vu que Image.open(infile) le fait déjà...
J'ai choppe ça quelque part sans obligatoirement comprendre tout ce que le programme fait. Dont acte.
Je pense que c'est moi qui fait une erreur.