# Python Imaging Library

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Python_Imaging_Library
> Markdown URL: https://mediated.wiki/source/Python_Imaging_Library.md
> Source: https://en.wikipedia.org/wiki/Python_Imaging_Library
> Source revision: 1347870042
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

**Python Imaging Library** is a [free and open-source](/source/Free_and_open-source_software) additional [library](/source/Library_(computing)) for the [Python programming language](/source/Python_(programming_language)) that adds support for opening, [manipulating](/source/Image_editing), and saving many different [image file formats](/source/Image_file_formats). It is available for [Windows](/source/Microsoft_Windows), [macOS](/source/MacOS) and [Linux](/source/Linux). The latest version of PIL is 1.1.7, was released in September 2009 and supports Python 1.5.2–2.7.[2]

Development of the original project, known as **PIL**, was discontinued in 2011.[3] Subsequently, a successor project named **Pillow** [forked](/source/Fork_(software_development)) the PIL repository and added Python 3.x support.[5] This fork has been adopted as a replacement for the original PIL in [Linux distributions](/source/Linux_distribution) including [Debian](/source/Debian_GNU/Linux)[6] and [Ubuntu](/source/Ubuntu) (since [13.04](/source/Ubuntu_version_history#1304)).[7]

## Capabilities

PIL offers several standard procedures for image manipulation. These include:

- per-pixel manipulations,[8]
- masking and transparency handling,
- image filtering, such as blurring, contouring, smoothing, or edge finding,[9]
- image enhancing, such as sharpening, adjusting brightness, contrast or color,[10]
- adding text

## File formats

Supported file formats include [PPM](/source/Netpbm_format), [PNG](/source/Portable_Network_Graphics), [JPEG](/source/JPEG), [GIF](/source/GIF), [TIFF](/source/TIFF), and [BMP](/source/BMP_file_format). PIL is extensible, allowing users to create custom decoders for any file format.[11]

## Programming examples

import os
from PIL import Image

def convert_jpegs_to_pngs(folder_path):
    # Checks if the provided path is a folder
    if not os.path.isdir(folder_path):
        print(f"Error: {folder_path} is not a valid folder.")
        return

    # Iterates over all files in the folder
    for filename in os.listdir(folder_path):
        # Checks if the file has a .jpg or .jpeg extension
        if filename.lower().endswith(".jpg") or filename.lower().endswith(".jpeg"):
            # Full path of the file
            jpeg_path = os.path.join(folder_path, filename)
            # Path for the converted file
            png_path = os.path.join(folder_path, os.path.splitext(filename)[0] + ".png")

            try:
                # Opens the JPEG image
                with Image.open(jpeg_path) as img:
                    # Converts and saves as PNG
                    img.save(png_path, "PNG")
                    print(f"Converted {jpeg_path} to {png_path}")
            except Exception as e:
                print(f"Error converting {jpeg_path}: {e}")

## References

1. ["Software License"](http://www.pythonware.com/products/pil/license.htm). *Secret Labs AB*. [Archived](https://web.archive.org/web/20200720222143/http://www.pythonware.com/products/pil/license.htm) 20 July 2020 at the Wayback Machine. Retrieved December 8, 2013.

1. ["Python Imaging Library"](http://www.pythonware.com/products/pil/). *Secret Labs AB*. [Archived](https://web.archive.org/web/20201121102218/http://www.pythonware.com/products/pil/) 21 November 2020 at the Wayback Machine. Retrieved December 8, 2013.

1. ["effbot / pil-2009-raclette"](http://hg.effbot.org/pil-2009-raclette). [Archived](https://web.archive.org/web/20150315041249/http://hg.effbot.org/pil-2009-raclette) 15 March 2015 at the Wayback Machine. Retrieved December 8, 2013.

1. ["Release Notes"](https://pillow.readthedocs.io/en/stable/releasenotes/). *Pillow (PIL Fork) Documentation*. Retrieved February 5, 2025.

1. ["Pillow: a modern fork of PIL"](https://pillow.readthedocs.org/en/latest/). Retrieved December 8, 2013.

1. ["Details of package python-imaging in sid"](http://packages.debian.org/sid/python-imaging). *packages.debian.org*. [Software in the Public Interest](/source/Software_in_the_Public_Interest). Retrieved December 8, 2013.

1. ["Details of package python-imaging in raring"](https://packages.ubuntu.com/raring/python/python-imaging). *ubuntu.com*. [Canonical Ltd.](/source/Canonical_Ltd.). Retrieved December 8, 2013.

1. ["PyAccess Module"](https://pillow.readthedocs.io/en/stable/reference/PyAccess.html). *readthedocs.io*. Retrieved September 20, 2024.

1. ["ImageFilter Module"](https://pillow.readthedocs.io/en/stable/reference/ImageFilter.html). *readthedocs.io*. Retrieved September 20, 2024.

1. ["ImageColor Module"](https://pillow.readthedocs.io/en/stable/reference/ImageColor.html). *readthedocs.io*. Retrieved September 20, 2024.

1. ["D. Writing Your Own File Decoder"](http://effbot.org/imagingbook/decoder.htm). Effbot.org. Retrieved 2014-01-28.

## External links

- [Official website](https://web.archive.org/web/20201121102218/http://www.pythonware.com/products/pil/)
- [PIL Library reference](https://web.archive.org/web/20200914010747/https://effbot.org/imagingbook/)
- [Pillow (Successor project)](https://python-pillow.github.io/)
- [PIL Tutorial Examples](https://gethowstuff.com/python-pillow-pil-tutorial-examples/)

---
Adapted from the Wikipedia article [Python Imaging Library](https://en.wikipedia.org/wiki/Python_Imaging_Library) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Python_Imaging_Library?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
