Home>Article>Backend Development> How to use pil in python3

How to use pil in python3

(*-*)浩
(*-*)浩 Original
2019-07-06 09:01:38 4212browse

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.

How to use pil in python3

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 thePython Tutorialcolumn 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn