📜  pil python install - Python (1)

📅  最后修改于: 2023-12-03 15:33:41.687000             🧑  作者: Mango

PIL Python Install - Python

PIL (Python Imaging Library) is a fork of the Python library PIL (Python Image Library) that adds support for opening, manipulating, and saving many different image file formats. PIL provides many image processing capabilities, such as resizing, cropping, and filtering. In this article, we will show you how to install PIL Python on your local machine.

Installing PIL on Windows
  1. Download the pre-built binary installer from this website. Make sure to select a version compatible with your version of Python.

  2. Open your command prompt and navigate to the directory where you saved the installer.

  3. Run the following command to install PIL:

    pip install <path/to/your/downloaded/pillow-version.whl>
    
  4. Once PIL is installed, test it by running the following code:

    from PIL import Image
    im = Image.open("image.jpg")
    im.show()
    

    This code should open a window displaying the image "image.jpg". If it does not, there may be an issue with your installation of PIL.

Installing PIL on Mac/Linux
  1. Open your terminal and navigate to your desired directory.

  2. Run the following command to install PIL:

    pip install pillow
    
  3. Once PIL is installed, test it by running the following code:

    from PIL import Image
    im = Image.open("image.jpg")
    im.show()
    

    This code should open a window displaying the image "image.jpg". If it does not, there may be an issue with your installation of PIL.

Conclusion

That's it! You have now installed PIL Python on your local machine. PIL is a powerful library with many capabilities, so be sure to explore its full potential. Happy coding!