Home > Article > Backend Development > How to use pil in python3
PIL (Python Imaging Library) is a powerful and convenient image processing library in Python, and it is also quite famous. However, it only supports Python 2.7.
Pillow is a fork of PIL, but has now developed into a more dynamic image processing library than PIL itself. The latest version currently is 3.0.0. (Recommended learning: Python video tutorial)
It is very simple to install Pillow for Python. It only takes one line of code to use pip or easy_install.
Use PIP to install on the command line:
pip install Pillow
Or use easy_install to install on the command line:
easy_install Pillow
After the installation is complete, Use from PIL import Image refers to the library. For example:
from PIL import Image im = Image.open("bride.jpg") im.rotate(45).show()
For example, the blur effect only requires a few lines of code:
from PIL import Image, ImageFilter # 打开一个jpg图像文件,注意是当前路径: im = Image.open('test.jpg') # 应用模糊滤镜: im2 = im.filter(ImageFilter.BLUR) im2.save('blur.jpg', 'jpeg')
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of How to use pil in python3. For more information, please follow other related articles on the PHP Chinese website!