PIL is the Python Imaging Library that provides image-processing capabilities in Python. The PIL.Image.new() method creates a new image with a specified mode, size, and optional color. An image can contain one or more bands, where each band represents a channel of image data.
Syntax
PIL.Image.new(mode, size, color)
Parameters
- mode: The mode to use for the new image. (It could be RGB, RGBA)
- size: A 2-tuple containing (width, height) in pixels.
- color: What color to use for the image. Default is black. If given, this should be a single integer or floating point value for single-band modes, and a tuple for multi-band modes.
- Return Value: An Image object.
Understanding Image Bands
It represents a single channel of image data that stores information about an image. A grayscale image has one band, while a color image such as RGB has three bands.
- Each band contains values representing a specific aspect of the image.
- In an RGB image, the three bands represent Red, Green, and Blue channels.
- Multi-band images contain two or more channels of image data.
Example 1: Creates a 200 × 200 RGB image with the default black color.
import PIL
im = PIL.Image.new(mode="RGB", size=(200, 200))
im.show()
Output:

Example 2: Creates a 200 × 200 RGB image with the color (153, 153, 255), where the tuple represents the Red, Green, and Blue values.
import PIL
im = PIL.Image.new(mode = "RGB", size = (200, 200),
color = (153, 153, 255))
im.show()
Output:

One can alter the value of color tuple to get different colors or we can simply use color name (for single band images).