+

Python PIL Attributes | Image.height method

The Image class has height attributes.

Image.height Image height in pixels. The attribute defines various properties of an object, element, or file.

Syntax: PIL.Image.height

Parameters:
image - image used of different extension.

Returns: height of the image

Image used:

  

  
# import Image module from PIL

from PIL import Image 

 
# open image

im = Image. open (r "C: UsersSystem-PcDesktopflower1.jpg"

 
# height attribute

im1 = im.height

print (im1)

Exit:

 225 

Another example: take another image with a .png extension.

Image used:

 

 
# import Image module from PIL

from PIL import Image 

 
# open image

im = Image. open (r " C: UsersSystem-PcDesktoppython .png "

  
# height attribute

im1 = im.height

print (im1)

Exit:

 149 
Get Solution for free from DataCamp guru