python图形处理库Python Imaging Library (PIL)简介及安装

来源:互联网 发布:汇编语言 多维数组 编辑:程序博客网 时间:2024/05/16 17:06
[简介] 
  这两天用python写一个程序,需要对各种格式的图片进行一些简单的处理,采用了Python Imaging Library (PIL)库,这个库可用于图片的一些常用操作,比如改变图片格式、尺寸、色彩、旋转等。 
  pil站点: http://www.pythonware.com/products/pil/index.htm 
  pil下载: http://effbot.org/downloads/Imaging-1.1.6.tar.gz 
  pil文档: http://www.pythonware.com/library/pil/handbook/index.htm 
   
  [安装] 
  $ gunzip Imaging-1.1.6.tar.gz 
  $ tar xvf Imaging-1.1.6.tar 
  $ cd Imaging-1.1.6 
  $ python setup.py build_ext -i 
  $ python selftest.py 
  $ python setup.py install 
  安装完毕后,可在python安装目录下的site-packages找到PIL安装目录。 

  [使用] 

  如果你想使用PIL的Image类,就直接import Image即可,详细的使用方法请阅读其文档。


2. 解决Python.h No such file or directory

1.可以先查看一下含python-devel的包

    yum search python | grep python-devel

2.64位安装python-devel.x86_64,32位安装python-devel.i686,我这里安装:

    sudo yum install python-devel.x86_64

3. 进入/usr/include/python2.7看一下现在有没有Python.h,版本不同目录名不同,我这里是2.7版本。其实也可以看到很多.h文件,python需要库或头文件都在这个地方。



0 0