In this tutorial, we will introduce how to get the width and height of an image using python pillow.
1.Open an image
from PIL import Image #read the image im = Image.open("sample-image.png")
2.Get the width and height of image
#image size width = im.size[0] height = im.size[1] print('Width of the image is:', width) print('Height of the image is:', height)
Run this code, you may get the ouput:
Width of the image is: 600 Height of the image is: 400