Opening image

You can open any image using PIL.Image.open() method.

Syntax: PIL.Image.open(fp, mode=’r’)

Code:

Python3




from PIL import Image
 
image = Image.open('nature.jpg')
image.show()


Output:

Python Pillow – Working with Images

In this article, we will see how to work with images using Pillow in Python. We will discuss basic operations like creating, saving, rotating images. So let’s get started discussing in detail but first, let’s see how to install pillow.

Installation

To install this package type the below command in the terminal.

pip install pillow

Similar Reads

Creating new image

You can create a new image using PIL.Image.new() method. This method creates a new image with the given mode and size. Size is given as a (width, height)-tuple, in pixels...

Opening image

...

Getting Information about the image

You can open any image using PIL.Image.open() method....

Renaming and Saving Image

...

Cropping the image

Getting the format of the image: obj.format method returns the format of the image file....

Rotating the image

...

Filtering the image

...

Creating a Watermark on the image

We can change the name, format of the image, and can also rename it using the image.save() method....