Image Module

Anonymous contributor's avatar
Anonymous contributor
Published Jun 7, 2024
Contribute to Docs

The Image module in Pillow, a popular Python library for image processing, provides a comprehensive suite of tools for opening, creating, manipulating, and saving images in various formats. It allows users to perform a wide range of operations such as resizing, cropping, rotating, and flipping images. Additionally, the module supports converting images between different modes (e.g., RGB to grayscale) and accessing or modifying individual pixels, making it a powerful and versatile tool for handling image data in Python applications.

Syntax

from PIL import Image

This statement imports the Image module from the Pillow library, which is a fork of the Python Imaging Library (PIL).

Image Module

.convert()
Converts an image from one mode to another.
.crop()
Returns a given image cropped to a specified rectangular area.
.putpixel()
Sets the color of a specific pixel in an image to a given value.
.resize()
Changes the size of an image to a specified size.
.rotate()
Rotates a given image anti-clockwise around its center by the specified number of degrees.
.transpose()
Flips or rotates an image according to the specified operation.
fromarray()
Creates an image from a specified array.

All contributors

Contribute to Docs

Learn Python:Pillow on Codecademy