Python Imaging Library
   HOME

TheInfoList



OR:

Python Imaging Library is a free and open-source additional
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
for the
Python programming language Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming p ...
that adds support for opening, manipulating, and saving many different
image file formats An Image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be ...
. It is available for
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ser ...
, and
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
. The latest version of PIL is 1.1.7, was released in September 2009 and supports Python 1.5.2–2.7. Development of the original project, known as PIL, was discontinued in 2011. Subsequently, a successor project named Pillow forked the PIL repository and added Python 3.x support. This fork has been adopted as a replacement for the original PIL in Linux distributions including Debian and
Ubuntu Ubuntu ( ) is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: '' Desktop'', ''Server'', and ''Core'' for Internet of things devices and robots. All ...
(since 13.04).


Capabilities

PIL offers several standard procedures for image manipulation. These include: * per-pixel manipulations, * masking and transparency handling, * image filtering, such as blurring, contouring, smoothing, or edge finding, * image enhancing, such as sharpening, adjusting brightness, contrast or color, * adding text to images and much more.


File formats

Some of the file formats supported are PPM, PNG, JPEG, GIF,
TIFF Tag Image File Format, abbreviated TIFF or TIF, is an image file format for storing raster graphics images, popular among graphic artists, the publishing industry, and photographers. TIFF is widely supported by scanning, faxing, word process ...
, and BMP. It is also possible to create new file decoders to expand the library of file formats accessible.


Example of use

This example loads an image from the file system, blurs it, and shows both the original and the blurred image on the screen: from PIL import Image, ImageFilter # Import classes from the library. original_image = Image.open("file.ppm") # Load an image from the file system. blurred_image = original_image.filter(ImageFilter.BLUR) # Blur the image. # Display both images. original_image.show() blurred_image.show() This example loads and rotates an image by 180 degrees: from PIL import Image # Import Image class from the library. image = Image.open("file.jpg") # Load the image. rotated_image = image.rotate(180) # Rotate the image by 180 degrees. rotated_image.save("file_rotated.jpg") # Save the rotated image. This example loads and crops an image: from PIL import Image # Import Image class from library. image = Image.open("example.jpg") # Load image. cropped_image = image.crop((100, 100, 250, 250)) # Crop the image. cropped_image.save("example_cropped.jpg") # Save the image.


License

The Python Imaging Library (PIL) is Copyright © 1997-2011 by Secret Labs AB Copyright © 1995-2011 by Fredrik Lundh Based o


References


External links

*
PIL Library reference
*{{wikibooks-inline, Python Imaging Library
Pillow (Successor project)PIL Tutorial Examples
Graphics libraries Python (programming language) libraries