HOME

TheInfoList



OR:

Python Imaging Library is a
free and open-source Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the 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 vi ...
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 par ...
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 b ...
. 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 ...
, 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, which i ...
. 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 distribution A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system. Linux users usually obtain their operating system by downloading on ...
s including
Debian Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of De ...
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 th ...
(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 JPEG ( ) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and im ...
, 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 processin ...
, 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