標籤:
安裝PIL
Mac或Linux安裝命令:sudo easy_install PIL
如果報錯:fatal error: ‘freetype/fterrors.h‘ file not found
Mac下所依賴的FreeType連結變更問題,解決如下:
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
sudo easy_install -U pil
如果出現問題:decoder jpeg not available
卸載你的PIL
下載libjpeg:http://www.ijg.org/files/jpegsrc.v7.tar.gz
安裝libjpeg:
$ tar zxvf jpegsrc.v7.tar.gz $ cd jpeg-7 $ ./configure --enable-shared --enable-static $ make $ sudo make install
下載PIL: http://effbot.org/downloads/Imaging-1.1.7.tar.gz
編輯setup.py,設定:
JPEG_ROOT = libinclude("/usr/local")
ZLIB_ROOT = libinclude("/usr/local")
安裝PIL
$ python setup.py build $ sudo python setup.py install --optimize=1 $ python selftest.py - Run the selftest to confirm PIL is installed ok $ sudo python setup.py install
重啟IDLE
使用例可參考:
執行個體
詳細瞭解PIL,請參考PIL官方文檔:
http://effbot.org/imagingbook/
Qrcode:產生二維碼
安裝 qrcode:sudo easy_install qrcode
測試代碼(在命令列輸入):qr "test" > test.png
PIL:Python Imaging Library(影像處理標準庫)