Pillow | Python Imaging Library | Computer Vision library

 by   python-pillow Python Version: 10.3.0 License: Non-SPDX

kandi X-RAY | Pillow Summary

kandi X-RAY | Pillow Summary

Pillow is a Python library typically used in Artificial Intelligence, Computer Vision, Deep Learning applications. Pillow has no bugs, it has no vulnerabilities, it has build file available and it has medium support. However Pillow has a Non-SPDX License. You can install using 'pip install Pillow' or download it from GitHub, PyPI.

The Python Imaging Library adds image processing capabilities to your Python interpreter. This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities. The core image library is designed for fast access to data stored in a few basic pixel formats. It should provide a solid foundation for a general image processing tool.

            kandi-support Support

              Pillow has a medium active ecosystem.
              It has 10903 star(s) with 2051 fork(s). There are 219 watchers for this library.
              There were 2 major release(s) in the last 6 months.
              There are 79 open issues and 2727 have been closed. On average issues are closed in 215 days. There are 25 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of Pillow is 10.3.0

            kandi-Quality Quality

              Pillow has 0 bugs and 0 code smells.

            kandi-Security Security

              Pillow has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              Pillow code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              Pillow has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              Pillow releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Pillow saves you 19159 person hours of effort in developing the same functionality from scratch.
              It has 40016 lines of code, 3149 functions and 279 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed Pillow and discovered the below as its top functions. This is intended to give you an instant insight into Pillow implemented functionality, and help decide if they suit your requirements.
            • Builds the list of supported extensions .
            • Sets up attributes .
            • Convert the image .
            • Read the bitmap .
            • Load the default font data .
            • Save an image .
            • Write multiple frames to fp .
            • Extract a value from the data .
            • Add application marker .
            • Compute the regular polygon vertices .
            Get all kandi verified functions for this library.

            Pillow Key Features

            No Key Features are available at this moment for Pillow.

            Pillow Examples and Code Snippets

            :class:.PngImagePlugin.iTXt Class
            Pythondot img1Lines of Code : 0dot img1License : Non-SPDX (NOASSERTION)
            copy iconCopy
            :param value: value for this key
            :param lang: language code
            :param tkey: UTF-8 version of the key name  
            What about PIL?
            Pythondot img2Lines of Code : 0dot img2License : Non-SPDX (NOASSERTION)
            copy iconCopy
            Prior to Pillow 2.0.0, very few image code changes were made. Pillow 2.0.0
            added Python 3 support and includes many bug fixes from many contributors.  
            Font size and offset methods
            Pythondot img3Lines of Code : 0dot img3License : Non-SPDX (NOASSERTION)
            copy iconCopy
            from PIL import Image, ImageDraw, ImageFont
            font = ImageFont.truetype("Tests/fonts/FreeMono.ttf")
            width, height = font.getsize("Hello world")
            left, top = font.getoffset("Hello world")
            im = Image.new("RGB", (100, 100))
            draw = ImageDraw.Draw(im)
            Pillow - Dds Image Plugin
            Pythondot img4Lines of Code : 189dot img4License : Non-SPDX
            copy iconCopy
            A Pillow loader for .dds files (S3TC-compressed aka DXTC)
            Jerome Leclanche 
            The contents of this file a  
            Pillow - anchors
            Pythondot img5Lines of Code : 23dot img5License : Non-SPDX
            copy iconCopy
            from PIL import Image, ImageDraw, ImageFont
            font = ImageFont.truetype("Tests/fonts/NotoSans-Regular.ttf", 16)
            def test(anchor):
                im = Image.new("RGBA", (200, 100), "white")
                d = ImageDraw.Draw(im)
                d.line(((100, 0), (100, 100)), "gray")
            How can I fix my python code to save and resize images using glob on linux
            Pythondot img6Lines of Code : 10dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from PIL import Image
            import glob
            for im in images:
                # print(im)
                img = Image.open(im)
                img = img.resize((100, 100), Image.ANTIALIAS)
            PIL Image not cropping the way I want
            Pythondot img7Lines of Code : 26dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import PIL
            from PIL import ImageEnhance
            from PIL import Image
            image =  Image.open("img.jpg").convert("RGB")
            contact_sheet = PIL.Image.new(image.mode,(1920,1080))
            enhancer = ImageEnhance.Color(image)
            images = []
            current_location = 0   
            PIL doesn't detect identical images
            Pythondot img8Lines of Code : 62dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            #!/usr/bin/env python3
            import numpy as np
            from PIL import Image
            # Load base image, extract alpha channel and bounding box and crop to it
            base = Image.open('base.png').getchannel('A')
            bbox = base.getbbox()
            print(f'Base image bbox: {bbox}'
            AttributeError when displaying image on streamlit web app
            Pythondot img9Lines of Code : 43dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pm4py
            import streamlit as st
            # from PIL import Image
            import pandas as pd
            import io
            d = {
                'case_id': [1, 1, 1, 2],
                'activity_id': ['Accepted', 'Awaiting Documentation',
                'Complete Activated', 'Approved'],
            Improve speed of getpixel and putpixel
            Pythondot img10Lines of Code : 102dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            #!/usr/bin/env python3
            from PIL import Image
            import numba as nb
            import numpy as np
            def Rainbow(i):
                x = 1 - abs(((i / 60) % 2) - 1)
                i %= 360
                if (i >= 0   and i < 60 ): r,g,b = 1, x, 0
                if (i >= 60  and i < 120):

            Community Discussions


            Improve speed of getpixel and putpixel
            Asked 2022-Apr-04 at 10:13

            Using PIL, I'm applying a rainbow filter to the given image using getpixel and setpixel. One issue, this method is very slow. It takes around 10 seconds to finish one image.



            Answered 2022-Apr-03 at 15:21

            You can convert image to NumPy.array then use numba for improving speed like below:

            Source https://stackoverflow.com/questions/71724930


            Find the minimum plane of the maximum number of black pixels in the bottom image. Find the peak of the black pixels for the top image
            Asked 2022-Mar-22 at 18:00

            This is the actual Image

            I want to find the distance between 2 irregular edges in a binary image. That is I have marked with red on the below image. My idea was to draw a colored line (say red) on both the edges and then calculate the distance between them at 10 equal intervals (yellow-colored marking)

            I cropped the image into two. Say the top half is

            Bottom half is

            I want to draw the two red lines or just find the distance between those two somehow. I have been using OpenCV and PILLOW for a lot of steps.

            there are also image instances where at few columns there are no black pixels in the top image. How do i calculate the distance of the black pixels only from the top? Just the top image.



            Answered 2022-Mar-22 at 18:00

            Here is one possible approach. I will leave the details to you. But the idea is to use Numpy argmax (or argmin as appropriate) to get the index of the first white after all black in each column. First I flip the image vertically so that the black is at the top. Numpy argmax, seems to find the first white value along the column.

            Input (bottom image):

            Source https://stackoverflow.com/questions/71574600


            unable to install pyodbc using python 3.10 in windows 10
            Asked 2022-Feb-24 at 20:07

            I get this Error when I try to install Pyodbc , I have already install visual studio and I have Microsoft Visual C++ 12 , 15-19 in my machine but still its giving this error.



            Answered 2021-Nov-12 at 13:38

            The current release of pyodbc (4.0.32) does not have pre-built wheel files for Python 3.10. The easiest way to get it installed at the moment is to download the appropriate wheel from


            and then install it. For example, if you are running 64-bit Python then you would download the 64-bit wheel and use

            Source https://stackoverflow.com/questions/69943254


            Colab: (0) UNIMPLEMENTED: DNN library is not found
            Asked 2022-Feb-08 at 19:27

            I have pretrained model for object detection (Google Colab + TensorFlow) inside Google Colab and I run it two-three times per week for new images I have and everything was fine for the last year till this week. Now when I try to run model I have this message:



            Answered 2022-Feb-07 at 09:19

            It happened the same to me last friday. I think it has something to do with Cuda instalation in Google Colab but I don't know exactly the reason

            Source https://stackoverflow.com/questions/71000120


            How to install local package with conda
            Asked 2022-Feb-05 at 04:16

            I have a local python project called jive that I would like to use in an another project. My current method of using jive in other projects is to activate the conda env for the project, then move to my jive directory and use python setup.py install. This works fine, and when I use conda list, I see everything installed in the env including jive, with a note that jive was installed using pip.

            But what I really want is to do this with full conda. When I want to use jive in another project, I want to just put jive in that projects environment.yml.

            So I did the following:

            1. write a simple meta.yaml so I could use conda-build to build jive locally
            2. build jive with conda build .
            3. I looked at the tarball that was produced and it does indeed contain the jive source as expected
            4. In my other project, add jive to the dependencies in environment.yml, and add 'local' to the list of channels.
            5. create a conda env using that environment.yml.

            When I activate the environment and use conda list, it lists all the dependencies including jive, as desired. But when I open python interpreter, I cannot import jive, it says there is no such package. (If use python setup.py install, I can import it.) How can I fix the build/install so that this works?

            Here is the meta.yaml, which lives in the jive project top level directory:



            Answered 2022-Feb-05 at 04:16

            The immediate error is that the build is generating a Python 3.10 version, but when testing Conda doesn't recognize any constraint on the Python version, and creates a Python 3.9 environment.

            I think the main issue is that python >=3.5 is only a valid constraint when doing noarch builds, which this is not. That is, once a package builds with a given Python version, the version must be constrained to exactly that version (up through minor). So, in this case, the package is built with Python 3.10, but it reports in its metadata that it is compatible with all versions of Python 3.5+, which simply isn't true because Conda Python packages install the modules into Python-version-specific site-packages (e.g., lib/python-3.10/site-packages/jive).

            Typically, Python versions are controlled by either the --python argument given to conda-build or a matrix supplied by the conda_build_config.yaml file (see documentation on "Build variants").

            Try adjusting the meta.yaml to something like

            Source https://stackoverflow.com/questions/70705250


            ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
            Asked 2022-Jan-28 at 03:50

            Error while installing manimce, I have been trying to install manimce library on windows subsystem for linux and after running



            Answered 2022-Jan-28 at 02:24
            apt-get install sox ffmpeg libcairo2 libcairo2-dev
            apt-get install texlive-full
            pip3 install manimlib  # or pip install manimlib

            Source https://stackoverflow.com/questions/70508775


            reticulate segfaults with call to plt.plot()
            Asked 2022-Jan-26 at 16:45

            I am encountering a segfault when I make a reticulated call to matplotlib.pyplot.plot().

            Steps to produce error:

            1. Create a Dockerfile with the contents:



            Answered 2022-Jan-26 at 16:45

            The problem is that the R binary in rocker/r-ver:latest is compiled against a different BLAS library to the one which the numpy on PyPI is compiled against.

            This was explained to me by Tomasz Kalinowski here.

            The solution is to ensure numpy uses the same BLAS libraries as rocker/r-ver's R binary does. An easy way to ensure this is to compile numpy from source. This compilation could be performed at either image build-time or container runtime.

            Compiling numpy at runtime

            To compile numpy at container runtime we can leave our Dockerfile as is, and add a call to system2() after our initial call to reticulate::virtualenv_create(). Altering test.R to become:

            Source https://stackoverflow.com/questions/70711946


            django rest Error - AttributeError: module 'collections' has no attribute 'MutableMapping'
            Asked 2022-Jan-07 at 19:13

            I'm build Django app, and it's work fine on my machine, but when I run inside docker container it's rest framework keep crashing, but when I comment any connection with rest framework it's work fine.

            • My machine: Kali Linux 2021.3
            • docker machine: Raspberry Pi 4 4gb
            • docker container image: python:rc-alpine3.14
            • python version on my machine: Python 3.9.7
            • python version on container: Python 3.10.0rc2

            error output:



            Answered 2022-Jan-07 at 19:13

            You can downgrade your Python version. That should solve your problem; if not, use collections.abc.Mapping instead of the deprecated collections.Mapping.

            Refer here: Link

            Source https://stackoverflow.com/questions/69464512


            Can't deploy streamlit app on share.streamlit.io
            Asked 2021-Dec-25 at 14:42

            I am working with a simple ML model with streamlit. It runs fine on my local machine inside conda environment, but it shows Error installing requirements when I try to deploy it on share.streamlit.io.
            The error message is the following:



            Answered 2021-Dec-25 at 14:42

            Streamlit share runs the app in a linux environment meaning there is no pywin32 because this is for windows.

            Delete the pywin32 from the requirements file and also the pywinpty==1.1.6 for the same reason.

            After deleting these requirements re-deploy your app and it will work.

            Source https://stackoverflow.com/questions/70480314


            Could not find a version that satisfies the requirement psycopg2
            Asked 2021-Dec-05 at 21:00

            I'm working on CI for my Python + Django project. I have to use the python:3.9-alpine image. A weird error is popping in my CI pipelines:



            Answered 2021-Dec-05 at 17:35

            What is the reason of my error?

            Did you read my previous answer to a similar question of yours? The last part warns about certain combinations of Alpine + Python and this seems to be happening right now.

            I tried to replace psycopg2 with psycopg2-binary but have the same error

            The problem here might be a python library that has dependencies on gcc, which is not shipped on alpine by default.

            Try replacing this:

            Source https://stackoverflow.com/questions/70235791

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install Pillow

            You can install using 'pip install Pillow' or download it from GitHub, PyPI.
            You can use Pillow like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • PyPI

            pip install pillow

          • CLONE
          • HTTPS


          • CLI

            gh repo clone python-pillow/Pillow

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link