python 圖像處理(從安裝Pillow開始)


python2.x及以下用的是PIL(圖像處理庫是 PIL(Python Image Library)),最新版本是 1.1.7  可在http://www.pythonware.com/products/pil/index.htm 下載和學習。

不過從該網站可看出它不支持python3.x 

Pillow由PIL而來(支持3.x),所以該導入該庫使用import PIL 

由於本人用的是python 3.4 所以下載的Pillow

關於下載第三方庫,有三種方法,之前用的都是

第一種方法

  1 下載第三方包,解壓

  2 在命令提示符里輸入cmd,然后用cd進入到第三方包的路徑下

  3 輸入python setup.py build

  4 輸入python setup.py install

效率低下

故這次打算安裝pip和easy_installer工具,通過代碼就可以安裝,

安裝可參考:http://heipark.iteye.com/blog/1916758 或者http://blog.chinaunix.net/uid-12014716-id-3859827.html(內有官網地址)

除此之外在相應的官網也提供詳細的安裝教程(Mac OS的話真是快很多)

easy_installer簡便安裝:

Windows (simplified) (官網說明)

For Windows without PowerShell 3 or for installation without a command-line, download ez_setup.py using your preferred web browser or other technique and “run” that file.

保存本地后運行就在安裝了,

pip安裝 法1:下載解壓,cd切換到pip的目錄,找到setup.py文件,然后輸入python setup.py install

最后顯示

Installed d:\python34\lib\site-packages\pip-7.1.2
Processing dependencies for pip==7.1.2
Finished processing dependencies for pip==7.1.2

法2(推薦):安裝完easy_install 后就可以執行這樣的命令了

C:\Users\Administrator>easy_install pip
Searching for pip
Best match: pip 7.1.2
Processing pip-7.1.2-py3.4.egg
pip 7.1.2 is already the active version in easy-install.pth
Installing pip-script.py script to D:\python34\Scripts
Installing pip.exe script to D:\python34\Scripts
Installing pip.exe.manifest script to D:\python34\Scripts
Installing pip3-script.py script to D:\python34\Scripts
Installing pip3.exe script to D:\python34\Scripts
Installing pip3.exe.manifest script to D:\python34\Scripts
Installing pip3.4-script.py script to D:\python34\Scripts
Installing pip3.4.exe script to D:\python34\Scripts
Installing pip3.4.exe.manifest script to D:\python34\Scripts

Using d:\python34\lib\site-packages\pip-7.1.2-py3.4.egg
Processing dependencies for pip
Finished processing dependencies for pip

 

那么接下來就是pip的使用(可參考http://www.th7.cn/Program/Python/201410/289949.shtml)

C:\Users\Administrator>pip install Pillow
Collecting Pillow
  Downloading Pillow-2.9.0-cp34-none-win32.whl (1.2MB)
    100% |████████████████████████████████|
Installing collected packages: Pillow
Successfully installed Pillow-2.9.0

那么pillow就安裝成功了

在Pillow的官網教程也有教程http://pillow.readthedocs.org/installation.html 多種安裝方式可參考

 

接下來

C:\Users\Administrator>python
Python 3.4.2 (v3.4.2:ab2c023a9
Type "help", "copyright", "cre
>>> 2
2
>>> from PIL import Image
>>>

沒報錯,說明安裝成功

接下來可在http://pillow.readthedocs.org/index.html開始學習,或參考他人blog 后面將繼續出圖像處理的例子~

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM