Python 如何安裝 PIL

本篇 ShengYu 將介紹 Python 如何安裝PIL,簡單的介紹 PIL 模組,以及 Pillow 與 PIL 之間的關係。

PIL 簡介

PIL(Python Imaging Library)是Python一個强大方便的影像處理函式庫。只支援到 Python 2.7。
PIL官方網站連結已失效。

Pillow 與 PIL 的關係

Pillow 是 PIL 的一个衍生的分支專案,但如今已经發展成為比 PIL 本身更活躍的影像處理函式庫。支援 Python2.7.x,和 Python3.5 以上。
Pillow 7.0.0 在 2020-01-02 釋出,且不支援 Python2.7。
目前最新版本是8.1.0(2021.01.03釋出)。

Pillow 的 Github:https://github.com/python-pillow/Pillow
Pillow 的官方文件:https://pillow.readthedocs.org/en/latest/handbook/index.html
Pillow 的文件中譯(2.4.0):https://pillow-cn.readthedocs.io/zh_CN/latest/
PyPI 的 Pillow:https://pypi.org/project/Pillow/

Python 3.x 安裝 Pillow

Python 安裝 Pillow 方法如下,
在命列列下使用 PIP 安裝,

1
$ pip install Pillow

或在命列列下使用 easy_install 安裝,

1
$ easy_install Pillow

安裝完成後,在 python 裡使用 from PIL import Image 就引用 PIL 函式庫了,Pillow 由 PIL 衍生而來,所以是 import PIL 而不是 Pillow 唷。

接下來就可以開始練習寫第一支PIL圖片處理程式囉!

安裝的 Pillow 模組會保存在 python 目錄下的 site-packages。

相關主題
Python 第一支 Python 程式
Python PIL 讀取圖片並顯示
Python 圖片模糊化 blur
Python 縮放圖片 resize
Python 在圖片上繪製文字