10 个 Python 图像编辑工具
Python 图像

> 
> 以下提到的这些 Python 工具在编辑图像、操作图像底层数据方面都提供了简单直接的方法。
> 
> 
> 


![](/data/attachment/album/201904/03/113908goodz6kdy9oc66pr.jpg)


当今的世界充满了数据，而图像数据就是其中很重要的一部分。但只有经过处理和分析，提高图像的质量，从中提取出有效地信息，才能利用到这些图像数据。


常见的图像处理操作包括显示图像，基本的图像操作，如裁剪、翻转、旋转；图像的分割、分类、特征提取；图像恢复；以及图像识别等等。Python 作为一种日益风靡的科学编程语言，是这些图像处理操作的最佳选择。同时，在 Python 生态当中也有很多可以免费使用的优秀的图像处理工具。


下文将介绍 10 个可以用于图像处理任务的 Python 库，它们在编辑图像、查看图像底层数据方面都提供了简单直接的方法。


### 1、scikit-image


[scikit-image](https://scikit-image.org/) 是一个结合 [NumPy](http://docs.scipy.org/doc/numpy/reference/index.html#module-numpy) 数组使用的开源 Python 工具，它实现了可用于研究、教育、工业应用的算法和应用程序。即使是对于刚刚接触 Python 生态圈的新手来说，它也是一个在使用上足够简单的库。同时它的代码质量也很高，因为它是由一个活跃的志愿者社区开发的，并且通过了<ruby> 同行评审 <rt>  peer review </rt></ruby>。


#### 资源


scikit-image 的[文档](http://scikit-image.org/docs/stable/user_guide.html)非常完善，其中包含了丰富的用例。


#### 示例


可以通过导入 `skimage` 使用，大部分的功能都可以在它的子模块中找到。


<ruby> 图像滤波 <rt>  image filtering </rt></ruby>：



```
import matplotlib.pyplot as plt
%matplotlib inline

from skimage import data,filters

image = data.coins() # ... or any other NumPy array!
edges = filters.sobel(image)
plt.imshow(edges, cmap='gray')
```

![Image filtering in scikit-image](/data/attachment/album/201904/03/113909w24q3hjhg2qjz0g8.png "Image filtering in scikit-image")


使用 [match\_template()](http://scikit-image.org/docs/dev/auto_examples/features_detection/plot_template.html#sphx-glr-auto-examples-features-detection-plot-template-py) 方法实现<ruby> 模板匹配 <rt>  template matching </rt></ruby>：


![Template matching in scikit-image](/data/attachment/album/201904/03/113910eijjkg19yrjd07hk.png "Template matching in scikit-image")


在[展示页面](https://scikit-image.org/docs/dev/auto_examples)可以看到更多相关的例子。


### 2、NumPy


[NumPy](http://www.numpy.org/) 提供了对数组的支持，是 Python 编程的一个核心库。图像的本质其实也是一个包含像素数据点的标准 NumPy 数组，因此可以通过一些基本的 NumPy 操作（例如切片、<ruby> 掩膜 <rt>  mask </rt></ruby>、<ruby> 花式索引 <rt>  fancy indexing </rt></ruby>等），就可以从像素级别对图像进行编辑。通过 NumPy 数组存储的图像也可以被 skimage 加载并使用 matplotlib 显示。


#### 资源


在 NumPy 的[官方文档](http://www.numpy.org/)中提供了完整的代码文档和资源列表。


#### 示例


使用 NumPy 对图像进行<ruby> 掩膜 <rt>  mask </rt></ruby>操作：



```
import numpy as np
from skimage import data
import matplotlib.pyplot as plt
%matplotlib inline

image = data.camera()
type(image)
numpy.ndarray #Image is a NumPy array:

mask = image < 87
image[mask]=255
plt.imshow(image, cmap='gray')
```

![NumPy](/data/attachment/album/201904/03/113910nyuuf7z8qpydyzwk.png "NumPy")


### 3、SciPy


像 NumPy 一样，[SciPy](https://www.scipy.org/) 是 Python 的一个核心科学计算模块，也可以用于图像的基本操作和处理。尤其是 SciPy v1.1.0 中的 [scipy.ndimage](https://docs.scipy.org/doc/scipy/reference/ndimage.html#module-scipy.ndimage) 子模块，它提供了在 n 维 NumPy 数组上的运行的函数。SciPy 目前还提供了<ruby> 线性和非线性滤波 <rt>  linear and non-linear filtering </rt></ruby>、<ruby> 二值形态学 <rt>  binary morphology </rt></ruby>、<ruby> B 样条插值 <rt>  B-spline interpolation </rt></ruby>、<ruby> 对象测量 <rt>  object measurements </rt></ruby>等方面的函数。


#### 资源


在[官方文档](https://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#correlation-and-convolution)中可以查阅到 `scipy.ndimage` 的完整函数列表。


#### 示例


使用 SciPy 的[高斯滤波](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter.html)对图像进行模糊处理：



```
from scipy import misc,ndimage

face = misc.face()
blurred_face = ndimage.gaussian_filter(face, sigma=3)
very_blurred = ndimage.gaussian_filter(face, sigma=5)

#Results
plt.imshow(<image to be displayed>)
```

![Using a Gaussian filter in SciPy](/data/attachment/album/201904/03/113911hw2eh1jebi2hjc3j.png "Using a Gaussian filter in SciPy")


### 4、PIL/Pillow


PIL (Python Imaging Library) 是一个免费 Python 编程库，它提供了对多种格式图像文件的打开、编辑、保存的支持。但在 2009 年之后 PIL 就停止发布新版本了。幸运的是，还有一个 PIL 的积极开发的分支 [Pillow](https://python-pillow.org/)，它的安装过程比 PIL 更加简单，支持大部分主流的操作系统，并且还支持 Python 3。Pillow 包含了图像的基础处理功能，包括像素点操作、使用内置卷积内核进行滤波、颜色空间转换等等。


#### 资源


Pillow 的[官方文档](https://pillow.readthedocs.io/en/3.1.x/index.html)提供了 Pillow 的安装说明自己代码库中每一个模块的示例。


#### 示例


使用 Pillow 中的 ImageFilter 模块实现图像增强：



```
from PIL import Image,ImageFilter
#Read image
im = Image.open('image.jpg')
#Display image
im.show()

from PIL import ImageEnhance
enh = ImageEnhance.Contrast(im)
enh.enhance(1.8).show("30% more contrast")
```

![Enhancing an image in Pillow using ImageFilter](/data/attachment/album/201904/03/113911l2klvtypay0vxtlv.png "Enhancing an image in Pillow using ImageFilter")


* [源码](http://sipi.usc.edu/database/)


### 5、OpenCV-Python


OpenCV（Open Source Computer Vision 库）是计算机视觉领域最广泛使用的库之一，[OpenCV-Python](https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_intro/py_intro.html) 则是 OpenCV 的 Python API。OpenCV-Python 的运行速度很快，这归功于它使用 C/C++ 编写的后台代码，同时由于它使用了 Python 进行封装，因此调用和部署的难度也不大。这些优点让 OpenCV-Python 成为了计算密集型计算机视觉应用程序的一个不错的选择。


#### 资源


入门之前最好先阅读 [OpenCV2-Python-Guide](https://github.com/abidrahmank/OpenCV2-Python-Tutorials) 这份文档。


#### 示例


使用 OpenCV-Python 中的<ruby> 金字塔融合 <rt>  Pyramid Blending </rt></ruby>将苹果和橘子融合到一起：


![Image blending using Pyramids in OpenCV-Python](/data/attachment/album/201904/03/113912jz8qw8rp6wtzzefp.jpg "Image blending using Pyramids in OpenCV-Python")


* [源码](https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_pyramids/py_pyramids.html#pyramids)


### 6、SimpleCV


[SimpleCV](http://simplecv.org/) 是一个开源的计算机视觉框架。它支持包括 OpenCV 在内的一些高性能计算机视觉库，同时不需要去了解<ruby> 位深度 <rt>  bit depth </rt></ruby>、文件格式、<ruby> 色彩空间 <rt>  color space </rt></ruby>之类的概念，因此 SimpleCV 的学习曲线要比 OpenCV 平缓得多，正如它的口号所说，“将计算机视觉变得更简单”。SimpleCV 的优点还有：


* 即使是刚刚接触计算机视觉的程序员也可以通过 SimpleCV 来实现一些简易的计算机视觉测试
* 录像、视频文件、图像、视频流都在支持范围内


#### 资源


[官方文档](http://examples.simplecv.org/en/latest/)简单易懂，同时也附有大量的学习用例。


#### 示例


![SimpleCV](/data/attachment/album/201904/03/113914m8mg2208kknztmmf.png "SimpleCV")


### 7、Mahotas


[Mahotas](https://mahotas.readthedocs.io/en/latest/) 是另一个 Python 图像处理和计算机视觉库。在图像处理方面，它支持滤波和形态学相关的操作；在计算机视觉方面，它也支持<ruby> 特征计算 <rt>  feature computation </rt></ruby>、<ruby> 兴趣点检测 <rt>  interest point detection </rt></ruby>、<ruby> 局部描述符 <rt>  local descriptors </rt></ruby>等功能。Mahotas 的接口使用了 Python 进行编写，因此适合快速开发，而算法使用 C++ 实现，并针对速度进行了优化。Mahotas 尽可能做到代码量少和依赖项少，因此它的运算速度非常快。可以参考[官方文档](https://openresearchsoftware.metajnl.com/articles/10.5334/jors.ac/)了解更多详细信息。


#### 资源


[文档](https://mahotas.readthedocs.io/en/latest/install.html)包含了安装介绍、示例以及一些 Mahotas 的入门教程。


#### 示例


Mahotas 力求使用少量的代码来实现功能。例如这个 [Finding Wally](https://blog.clarifai.com/wheres-waldo-using-machine-learning-to-find-all-the-waldos) 游戏：


![Finding Wally problem in Mahotas](/data/attachment/album/201904/03/113915bo76fif7ob1ygy9o.png "Finding Wally problem in Mahotas")


![Finding Wally problem in Mahotas](/data/attachment/album/201904/03/113916evwafw4hvwhq8rqb.png "Finding Wally problem in Mahotas")


* [源码](https://mahotas.readthedocs.io/en/latest/wally.html)


### 8、SimpleITK


[ITK](https://itk.org/)（Insight Segmentation and Registration Toolkit）是一个为开发者提供普适性图像分析功能的开源、跨平台工具套件，[SimpleITK](http://www.simpleitk.org/) 则是基于 ITK 构建出来的一个简化层，旨在促进 ITK 在快速原型设计、教育、解释语言中的应用。SimpleITK 作为一个图像分析工具包，它也带有[大量的组件](https://itk.org/ITK/resources/resources.html)，可以支持常规的滤波、图像分割、<ruby> 图像配准 <rt>  registration </rt></ruby>功能。尽管 SimpleITK 使用 C++ 编写，但它也支持包括 Python 在内的大部分编程语言。


#### 资源


有很多 [Jupyter Notebooks](http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/) 用例可以展示 SimpleITK 在教育和科研领域中的应用，通过这些用例可以看到如何使用 Python 和 R 利用 SimpleITK 来实现交互式图像分析。


#### 示例


使用 Python + SimpleITK 实现的 CT/MR 图像配准过程：


![SimpleITK animation](/data/attachment/album/201904/03/113931lfirzfq3z7eqypq3.gif "SimpleITK animation")


* [源码](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Utilities/intro_animation.py)


### 9、pgmagick


[pgmagick](https://pypi.org/project/pgmagick/) 是使用 Python 封装的 GraphicsMagick 库。[GraphicsMagick](http://www.graphicsmagick.org/) 通常被认为是图像处理界的瑞士军刀，因为它强大而又高效的工具包支持对多达 88 种主流格式图像文件的读写操作，包括 DPX、GIF、JPEG、JPEG-2000、PNG、PDF、PNM、TIFF 等等。


#### 资源


pgmagick 的 [GitHub 仓库](https://github.com/hhatto/pgmagick)中有相关的安装说明、依赖列表，以及详细的[使用指引](https://pgmagick.readthedocs.io/en/latest/)。


#### 示例


图像缩放：


![Image scaling in pgmagick](/data/attachment/album/201904/03/113932lavabuxxnvud84uv.png "Image scaling in pgmagick")


* [源码](https://pgmagick.readthedocs.io/en/latest/cookbook.html#scaling-a-jpeg-image)


边缘提取：


![Edge extraction in pgmagick](/data/attachment/album/201904/03/113933mroouhu2fnrfxx00.png "Edge extraction in pgmagick")


* [源码](https://pgmagick.readthedocs.io/en/latest/cookbook.html#edge-extraction)


### 10、Pycairo


[Cairo](https://cairographics.org/) 是一个用于绘制矢量图的二维图形库，而 [Pycairo](https://pypi.org/project/pycairo/) 是用于 Cairo 的一组 Python 绑定。矢量图的优点在于做大小缩放的过程中不会丢失图像的清晰度。使用 Pycairo 可以在 Python 中调用 Cairo 的相关命令。


#### 资源


Pycairo 的 [GitHub 仓库](https://github.com/pygobject/pycairo)提供了关于安装和使用的详细说明，以及一份简要介绍 Pycairo 的[入门指南](https://pycairo.readthedocs.io/en/latest/tutorial.html)。


#### 示例


使用 Pycairo 绘制线段、基本图形、<ruby> 径向渐变 <rt>  radial gradients </rt></ruby>：


![Pycairo](/data/attachment/album/201904/03/113934to6waz70p67i7u6u.png "Pycairo")


* [源码](http://zetcode.com/gfx/pycairo/basicdrawing/)


### 总结


以上就是 Python 中的一些有用的图像处理库，无论你有没有听说过、有没有使用过，都值得试用一下并了解它们。




---


via: <https://opensource.com/article/19/3/python-image-manipulation-tools>


作者：[Parul Pandey](https://opensource.com/users/parul-pandey) 选题：[lujun9972](https://github.com/lujun9972) 译者：[HankChow](https://github.com/HankChow) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Today's world is full of data, and images form a significant part of this data. However, before they can be used, these digital images must be processed—analyzed and manipulated in order to improve their quality or extract some information that can be put to use.

Common image processing tasks include displays; basic manipulations like cropping, flipping, rotating, etc.; image segmentation, classification, and feature extractions; image restoration; and image recognition. Python is an excellent choice for these types of image processing tasks due to its growing popularity as a scientific programming language and the free availability of many state-of-the-art image processing tools in its ecosystem.

This article looks at 10 of the most commonly used Python libraries for image manipulation tasks. These libraries provide an easy and intuitive way to transform images and make sense of the underlying data.

## 1. scikit-image

is an open source Python package that works with

**scikit**-image

[NumPy](http://docs.scipy.org/doc/numpy/reference/index.html#module-numpy)arrays. It implements algorithms and utilities for use in research, education, and industry applications. It is a fairly simple and straightforward library, even for those who are new to Python's ecosystem. The code is high-quality, peer-reviewed, and written by an active community of volunteers.

### Resources

scikit-image is very well [documented](http://scikit-image.org/docs/stable/user_guide.html) with a lot of examples and practical use cases.

### Usage

The package is imported as **skimage**, and most functions are found within the submodules.

Image filtering:

```
import matplotlib.pyplot as plt
%matplotlib inline
from skimage import data,filters
image = data.coins() # ... or any other NumPy array!
edges = filters.sobel(image)
plt.imshow(edges, cmap='gray')
```



![Image filtering in scikit-image Image filtering in scikit-image](https://opensource.com/sites/default/files/uploads/1-scikit-image.png)

Template matching using the [match_template](http://scikit-image.org/docs/dev/auto_examples/features_detection/plot_template.html#sphx-glr-auto-examples-features-detection-plot-template-py) function:

![Template matching in scikit-image Template matching in scikit-image](https://opensource.com/sites/default/files/uploads/2-scikit-image.png)

You can find more examples in the [gallery](https://scikit-image.org/docs/dev/auto_examples).

## 2. NumPy

[ NumPy](http://www.numpy.org/) is one of the core libraries in Python programming and provides support for arrays. An image is essentially a standard NumPy array containing pixels of data points. Therefore, by using basic NumPy operations, such as slicing, masking, and fancy indexing, you can modify the pixel values of an image. The image can be loaded using

**skimage**and displayed using Matplotlib.

### Resources


A complete list of resources and documentation is available on NumPy's [official documentation page](http://www.numpy.org/).

### Usage

Using Numpy to mask an image:

```
import numpy as np
from skimage import data
import matplotlib.pyplot as plt
%matplotlib inline
image = data.camera()
type(image)
numpy.ndarray #Image is a NumPy array:
mask = image < 87
image[mask]=255
plt.imshow(image, cmap='gray')
```



![NumPy NumPy](https://opensource.com/sites/default/files/uploads/3-numpy.png)

## 3. SciPy

** SciPy** is another of Python's core scientific modules (like NumPy) and can be used for basic image manipulation and processing tasks. In particular, the submodule

[(in SciPy v1.1.0) provides functions operating on n-dimensional NumPy arrays. The package currently includes functions for linear and non-linear filtering, binary morphology, B-spline interpolation, and object measurements.](https://docs.scipy.org/doc/scipy/reference/ndimage.html#module-scipy.ndimage)

**scipy.ndimage**### Resources

For a complete list of functions provided by the **scipy.ndimage** package, refer to the [documentation](https://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#correlation-and-convolution).

### Usage

Using SciPy for blurring using a [Gaussian filter](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter.html):

```
from scipy import misc,ndimage
face = misc.face()
blurred_face = ndimage.gaussian_filter(face, sigma=3)
very_blurred = ndimage.gaussian_filter(face, sigma=5)
#Results
plt.imshow(<image to be displayed>)
```



![Using a Gaussian filter in SciPy Using a Gaussian filter in SciPy](https://opensource.com/sites/default/files/uploads/4-scipy.png)

## 4. PIL/Pillow

**PIL** (Python Imaging Library) is a free library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats. However, its development has stagnated, with its last release in 2009. Fortunately, there is [ Pillow](https://python-pillow.org/), an actively developed fork of PIL, that is easier to install, runs on all major operating systems, and supports Python 3. The library contains basic image processing functionality, including point operations, filtering with a set of built-in convolution kernels, and color-space conversions.

### Resources

The [documentation](https://pillow.readthedocs.io/en/3.1.x/index.html) has instructions for installation as well as examples covering every module of the library.

### Usage

Enhancing an image in Pillow using ImageFilter:

```
from PIL import Image,ImageFilter
#Read image
im = Image.open('image.jpg')
#Display image
im.show()
from PIL import ImageEnhance
enh = ImageEnhance.Contrast(im)
enh.enhance(1.8).show("30% more contrast")
```



![Enhancing an image in Pillow using ImageFilter Enhancing an image in Pillow using ImageFilter](https://opensource.com/sites/default/files/uploads/5-pillow.png)

## 5. OpenCV-Python

**OpenCV** (Open Source Computer Vision Library) is one of the most widely used libraries for computer vision applications. [ OpenCV-Python](https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_intro/py_intro.html) is the Python API for OpenCV. OpenCV-Python is not only fast, since the background consists of code written in C/C++, but it is also easy to code and deploy (due to the Python wrapper in the foreground). This makes it a great choice to perform computationally intensive computer vision programs.

### Resources

The [OpenCV2-Python-Guide](https://github.com/abidrahmank/OpenCV2-Python-Tutorials) makes it easy to get started with OpenCV-Python.

### Usage

Using *Image Blending using Pyramids* in OpenCV-Python to create an "Orapple":

![Image blending using Pyramids in OpenCV-Python Image blending using Pyramids in OpenCV-Python](https://opensource.com/sites/default/files/uploads/6-opencv.jpeg)

## 6. SimpleCV

[ SimpleCV](http://simplecv.org/) is another open source framework for building computer vision applications. It offers access to several high-powered computer vision libraries such as OpenCV, but without having to know about bit depths, file formats, color spaces, etc. Its learning curve is substantially smaller than OpenCV's, and (as its tagline says), "it's computer vision made easy." Some points in favor of SimpleCV are:

- Even beginning programmers can write simple machine vision tests
- Cameras, video files, images, and video streams are all interoperable

### Resources

The official [documentation](http://examples.simplecv.org/en/latest/) is very easy to follow and has tons of examples and use cases to follow.

### Usage

![SimpleCV SimpleCV](https://opensource.com/sites/default/files/uploads/7-_simplecv.png)

## 7. Mahotas

** Mahotas** is another computer vision and image processing library for Python. It contains traditional image processing functions such as filtering and morphological operations, as well as more modern computer vision functions for feature computation, including interest point detection and local descriptors. The interface is in Python, which is appropriate for fast development, but the algorithms are implemented in C++ and tuned for speed. Mahotas' library is fast with minimalistic code and even minimum dependencies. Read its

[official paper](https://openresearchsoftware.metajnl.com/articles/10.5334/jors.ac/)for more insights.

### Resources

The [documentation](https://mahotas.readthedocs.io/en/latest/install.html) contains installation instructions, examples, and even some tutorials to help you get started using Mahotas easily.

### Usage

The Mahotas library relies on simple code to get things done. For example, it does a good job with the [Finding Wally](https://blog.clarifai.com/wheres-waldo-using-machine-learning-to-find-all-the-waldos) problem with a minimum amount of code.

Solving the Finding Wally problem:

![Finding Wally problem in Mahotas Finding Wally problem in Mahotas](https://opensource.com/sites/default/files/uploads/8-mahotas.png)

![Finding Wally problem in Mahotas Finding Wally problem in Mahotas](https://opensource.com/sites/default/files/uploads/9-mahotas.png)

## 8. SimpleITK

[ ITK](https://itk.org/) (Insight Segmentation and Registration Toolkit) is an "open source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.

**is a simplified layer built on top of ITK, intended to facilitate its use in rapid prototyping, education, [and] interpreted languages." It's also an image analysis toolkit with a**

[SimpleITK](http://www.simpleitk.org/)[large number of components](https://itk.org/ITK/resources/resources.html)supporting general filtering operations, image segmentation, and registration. SimpleITK is written in C++, but it's available for a large number of programming languages including Python.

### Resources

There are a large number of [Jupyter Notebooks](http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/) illustrating the use of SimpleITK for educational and research activities. The notebooks demonstrate using SimpleITK for interactive image analysis using the Python and R programming languages.

### Usage

Visualization of a rigid CT/MR registration process created with SimpleITK and Python:

![SimpleITK animation SimpleITK animation](https://opensource.com/sites/default/files/uploads/10-simpleitk.gif)

## 9. pgmagick

[ pgmagick](https://pypi.org/project/pgmagick/) is a Python-based wrapper for the GraphicsMagick library. The

[image processing system is sometimes called the Swiss Army Knife of image processing. Its robust and efficient collection of tools and libraries supports reading, writing, and manipulating images in over 88 major formats including DPX, GIF, JPEG, JPEG-2000, PNG, PDF, PNM, and TIFF.](http://www.graphicsmagick.org/)

**GraphicsMagick**### Resources

pgmagick's [GitHub repository](https://github.com/hhatto/pgmagick) has installation instructions and requirements. There is also a detailed [user guide](https://pgmagick.readthedocs.io/en/latest/).

### Usage

Image scaling:

![Image scaling in pgmagick Image scaling in pgmagick](https://opensource.com/sites/default/files/uploads/11-pgmagick.png)

Edge extraction:

![Edge extraction in pgmagick Edge extraction in pgmagick](https://opensource.com/sites/default/files/uploads/12-pgmagick.png)

## 10. Pycairo

[ Pycairo](https://pypi.org/project/pycairo/) is a set of Python bindings for the

[Cairo](https://cairographics.org/)graphics library. Cairo is a 2D graphics library for drawing vector graphics. Vector graphics are interesting because they don't lose clarity when resized or transformed. Pycairo can call Cairo commands from Python.

### Resources

The Pycairo [GitHub repository](https://github.com/pygobject/pycairo) is a good resource with detailed instructions on installation and usage. There is also a [getting started guide](https://pycairo.readthedocs.io/en/latest/tutorial.html), which has a brief tutorial on Pycairo.

### Usage

Drawing lines, basic shapes, and radial gradients with Pycairo:

![Pycairo Pycairo](https://opensource.com/sites/default/files/uploads/13-pycairo.png)

## Conclusion

These are some of the useful and freely available image processing libraries in Python. Some are well known and others may be new to you. Try them out to get to know more about them!

## 2 Comments