Getting Information about the image
- Getting the format of the image: obj.format method returns the format of the image file.
Python3
from PIL import Image img = Image. open ( "test.png" ) print (img. format ) |
Output:
PNG
- Getting the size of the image: obj.size attribute provides the size of the image. It returns a tuple that contains width and height.
Python3
from PIL import Image img = Image. open ( "test.png" ) print (img.size) |
Output:
(180, 263)
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