10+ Best Python Graphics Libraries

Python is one of the most popular interpreted programming languages, and it is meant to promote code readability and syntactic simplicity. Python has a robust graphics processing capabilities. In addition to various built-in visual processing modules, a wide range of third-party graphic processing open source softwares are available. This article focuses on some of the most popular and actively-maintained Python graphics libraries for various computation tasks, such as picture rendering, chart generation, image recognition, and other features.

Pillow – image manipulation with Python

Pillow - image manipulation with Python

If you’re looking for a Python library to work with images, you have to check out Pillow. It’s a continuation of PIL ( Python Imaging Library) – a long standing open source library for graphics manipulation written entirely in Python, which hasn’t been active since 2009.

The library only needs zlib and libjpeg to do basic features such as image rotation, resizing, transformation. Extended functionality can be enabled by installing other libraries, for example, libtiff provides compressed TIFF manipulation and libwebp allows Pillow to read and write WebP format. There are also pre-built Docker images to quickly install the dependencies for popular operating systems.

Each version of Pillow only supports a specific set of Python versions. You can look them up at Python Support Matrix here.

Pillow Homepage

Pillow Documentation

Python-OpenCV – image and video analysis with Python

Python-OpenCV - image and video analysis with Python

OpenCV is the standard for image and video analysis. The library was originally written in C and was equipped with over 2,500 optimized, professionally designed algorithms. It has native Python interface and supports Windows, Linux, Android and Mac OS. Among the interfaces, the Python one is the most popular as it integrates well with the machine learning and data analysis package ecosystem in Python.

Python-OpenCV in PyPI

OpenCV documentation

Pyvips – compress images with Python

Pyvips - compress images with Python

Pyvips is the Python wrapper for libvips – an open source, horizontally threaded image processing library. Compared to similar libraries, libvips runs quickly and uses little memory.

Libvips supports more than 300 image operations covering arithmetic, histograms, convolution, morphological operations, frequency filtering, colour, resampling, statistics and others. It supports a broad range of image formats, including JPEG, TIFF, PNG, WebP, FITS, Matlab, OpenEXR, PDF, SVG, HDR, PPM, CSV, GIF, Analyze, NIfTI, DeepZoom, and OpenSlide. It can also integrate well with ImageMagick or GraphicsMagick, letting it load formats like DICOM.

Pyvips on Github

Pyvips documentation


PyMatting is a collection of algorithms that solves the alpha matting problem. If you didn’t know what alpha matting is, look at the image below and you’ll get an idea.


To put it simply, given an input image and an user-specified, hand-drawn trimap, PyMatting will estimate the alpha channel of the foreground object based on that trimap, then it can be later used to compose onto a different background image.

PyMatting Documentation: https://pymatting.github.io/

Benchmarks: https://pymatting.github.io/benchmark.html

Pywal – generate color palette from images

Pywal - generate color palette from images

Pywal is a small Python library to generate a color palette from the dominant colors of an image. The color palette can then be applied system-wide to popular applications. This is great for anyone who wants their terminals and programs to match with their favourite wallpapers.

Pywal on Github

Pywal on r/unixporn

Pygal – create SVG charts in Python

Pygal - create SVG charts in Python

SVG is the image format of the modern web. It can scale to any size without losing clarity, looks great on high-resolution displays and can be easily embedded to web pages. Pygal is a dynamic SVG charting library written entirely in Python, capable of creating good-looking, responsive charts. Using Pygal, you can generate a complex SVG chart in just a few lines of code. A few demos are available at Pygal documentation page, have a look.

Pygal homepage and documentation

PyGal on Github

Matplotlib – create data visualizations with Python

Matplotlib - create data visualizations with Python

Matplotlib is a library in Python that enables users to generate visualizations like histograms, scatterplots, bar charts, pie charts and so on. It is particularly popular in the data science world, often used to create visualizations and get insights out of raw data.

Matplotlib provides mechanisms to work with data frames and arrays, which are the native formats of other popular Python libraries such as NumPy and Pandas. The pyplot module mimics the MATLAB plotting commands closely. Hence, MATLAB users can easily switch to plotting with Python with little to no effort.

Matplotlib Homepage

Seaborn – Data visualization on steroid

Seaborn - Data visualization on steroid

The Seaborn package was developed on top of the Matplotlib library. It is used to create more attractive and informative statistical graphics.

Seaborn syntax is simpler than Matplotlib, meanwhile, it can be used to create more appealing visualizations. The library avoids a ton of boilerplate code by providing default themes which are commonly used. Once you’ve mastered Matplotlib, you may want to move up to Seaborn for more complex visualizations.

Seaborn Homepage

Bokeh – interactive visualization with Python

Bokeh - interactive visualization with Python

Bokeh is a Python interactive visualization library built for the modern web. The project is separated into two parts : Bokeh server which acts as the visualization engine and BokehJS is the in-browser client-side runtime library that users of Bokeh ultimately interact with.

With Bokeh, you can create JavaScript-powered visualizations without writing any JavaScript yourself. The library can help you build beautiful web graphics, ranging from simple plots to complex dashboards with streaming datasets with Python code only.

Bokeh homepage

Bokeh documentation

ImageAI – apply machine learning to applications with Python

ImageAI - apply machine learning to applications with Python

ImageAI is an open source library to make it easy to apply state of the art Machine Learning algorithms to applications.

It currently supports pre-trained models on ImageNet-100 dataset for image prediction, custom image prediction, object detection, video detection, video object tracking and image predictions training.

In addition to that, ImageAI also supports object detection, video detection and object tracking using RetinaNet, YOLOv3 and TinyYOLOv3 trained on COCO dataset.

ImageAI requires Python 3.7.6 , OpenCV, Tensorflow and Keras installed on your system to be able to function properly.The library is compatible with Tensorflow 2.x, up to version 2.4.0 at the time of this writing.

ImageAI on Github

Pytesseract – OCR with Google’s Tesseract and Python

Pytesseract - OCR with Google’s Tesseract and Python

Pyterreract (Python-tesseract) Python-tesseract is a wrapper for Google’s Tesseract-OCR Engine.

The library acts as a tool to expose Tesseract API as well as a stand-alone invocation script to tesseract. It can read all image types supported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff, and others. Additionally, if used as a script, Python-tesseract will print the recognized text instead of writing it to a file.

PyTesseract on PyPI

PyTesseract on Github

face_recognition – Simple facial recognition with Python

face_recognition - Simple facial recognition with Python

Face_recognition is a Python library that package the dlib’s state-of-the-art face recognition built with deep learning into Python. The library make it easy to accurately detect faces in images, with a success rate of over 99%.

You can either use face_recognition as a command line tool to batch-process a bunch of images, or use its API to build another application on top of it.

Code and examples are available in face_recognition Github repo.

Face_recognition Documentation

Troubleshooting common problems

Face_recognition Jupyter Notebook demo

Pre-configured VM images

Leave a Comment