
- Python Pillow - Home
- Python Pillow - Overview
- Python Pillow - Environment Setup
- Basic Image Operations
- Python Pillow - Working with Images
- Python Pillow - Resizing an Image
- Python Pillow - Flip and Rotate Images
- Python Pillow - Cropping an Image
- Python Pillow - Adding Borders to Images
- Python Pillow - Identifying Image Files
- Python Pillow - Merging Images
- Python Pillow - Cutting and Pasting Images
- Python Pillow - Rolling an Image
- Python Pillow - Writing text on image
- Python Pillow - ImageDraw Module
- Python Pillow - Concatenating two Images
- Python Pillow - Creating Thumbnails
- Python Pillow - Creating a Watermark
- Python Pillow - Image Sequences
- Python Pillow Color Conversions
- Python Pillow - Colors on an Image
- Python Pillow - Creating Images With Colors
- Python Pillow - Converting Color String to RGB Color Values
- Python Pillow - Converting Color String to Grayscale Values
- Python Pillow - Change the Color by Changing the Pixel Values
- Image Manipulation
- Python Pillow - Reducing Noise
- Python Pillow - Changing Image Modes
- Python Pillow - Compositing Images
- Python Pillow - Working with Alpha Channels
- Python Pillow - Applying Perspective Transforms
- Image Filtering
- Python Pillow - Adding Filters to an Image
- Python Pillow - Convolution Filters
- Python Pillow - Blur an Image
- Python Pillow - Edge Detection
- Python Pillow - Embossing Images
- Python Pillow - Enhancing Edges
- Python Pillow - Unsharp Mask Filter
- Image Enhancement and Correction
- Python Pillow - Enhancing Contrast
- Python Pillow - Enhancing Sharpness
- Python Pillow - Enhancing Color
- Python Pillow - Correcting Color Balance
- Python Pillow - Removing Noise
- Image Analysis
- Python Pillow - Extracting Image Metadata
- Python Pillow - Identifying Colors
- Advanced Topics
- Python Pillow - Creating Animated GIFs
- Python Pillow - Batch Processing Images
- Python Pillow - Converting Image File Formats
- Python Pillow - Adding Padding to an Image
- Python Pillow - Color Inversion
- Python Pillow - M L with Numpy
- Python Pillow with Tkinter BitmapImage and PhotoImage objects
- Image Module
- Python Pillow - Image Blending
- Python Pillow Useful Resources
- Python Pillow - Quick Guide
- Python Pillow - Function Reference
- Python Pillow - Useful Resources
- Python Pillow - Discussion
Python Pillow - Changing Image Modes
What is Changing Image Modes?
In Pillow changing image modes refers to the process of converting an image from one color representation to another. Each mode represents a different way of encoding and interpreting color information in an image.
Changing image modes is useful for various purposes such as preparing images for specific applications like printing, display or analysis. It allows us to adapt the color representation of an image to better suit our needs.
In Pillow the Image class provides a method called convert() that allows us to change the mode of an image. The mode of an image determines the type and depth of pixel values it can contain.
The following is the syntax and parameters of the convert() method of the Image class.
original_image.convert(mode)
Where,
original_image This is the source image whose mode we want to change.
mode This is a string specifying the desired mode for the new image.
The below are the common changing Image modes.
L − 8-bit pixels represent black and white
RGB − 3x8-bit pixels represent true color
RGBA − 4x8-bit pixels represent true color with transparency
CMYK − 4x8-bit pixels represent color separation
HSV − Hue, saturation, value color space
1 − 1-bit pixels, black and white which stored with one pixel per byte
Following is the input image used in all the examples of this chapter.

Example
In this example we are changing the image mode into black and white by passing the mode argument as L to the convert() method.
from PIL import Image #Open an image original_image = Image.open("Images/rose.jpg") #Convert the image to grayscale (mode 'L') grayscale_image = original_image.convert("L") #Save the resulting image grayscale_image.save("output Image/output_grayscale.jpg") grayscale_image.show()
Output

Example
Here is the another example of changing the image mode to 1 by using the convert() method.
from PIL import Image #Open an image original_image = Image.open("Images/rose.jpg") #Convert the image to RGBA mode single_image = original_image.convert("1") #Save the resulting image single_image.save("output Image/output_single_image.jpg") single_image.show()
Output
