下载PIL库
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$ tar xvfz Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7
打开setup.py
找到下面这几行
TCL_ROOT = None
JPEG_ROOT = JPEG库目录
ZLIB_ROOT = PNG和ZLIB库目录
TIFF_ROOT = TIFF库目录
FREETYPE_ROOT = FreeType库目录
LCMS_ROOT = None
安装libjpeg,默认路径/usr/local/lib
$ wget http://219.238.7.66/files/4029000007B700B5/www.ijg.org/files/jpegsrc.v9b.tar.gz
$ cd jpeg-9b
$ tar jpegsrc.v9b.tar.gz
$ ./configure --enable-shared --enable-static
$ make
$ sudo make install
安装zlib,默认路径/usr/local/lib
wget http://zlib.net/zlib-1.2.8.tar.gz
$ tar zxvf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure
$ make
$ sudo make install
如果出现“X11”的错误,执行命令
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
这样安装几个库完成,改下setup.py参数为
TCL_ROOT = None
JPEG_ROOT = "/usr/local/include"
ZLIB_ROOT = "/usr/local/include"
TIFF_ROOT = None
FREETYPE_ROOT = "/usr/local/include"
LCMS_ROOT = None
$ cd Imaging-1.1.7
$ python setup.py build_ext -i
$ python selftest.py
$ sudo python setup.py install
一路走,最后安装完毕写个case测测
import Image
im = Image.open("test.jpg")
im.save("test1.jpg")
网友评论