Python Program - Find the Size (Resolution) of a Image

www.igif‮aedit‬.com

here's a Python program that finds the size (resolution) of an image:

# Import the Image module from the PIL (Python Imaging Library) package
from PIL import Image

# Open the image file
image = Image.open("my_image.jpg")

# Get the size of the image
width, height = image.size

# Print the size of the image
print("Width: ", width)
print("Height:", height)

In this program, we first import the Image module from the PIL package, which provides image processing functionality.

We then open an image file called my_image.jpg using the Image.open() method, and store the resulting image object in the image variable.

We can then get the size of the image using the size attribute of the image object. The size attribute returns a tuple containing the width and height of the image in pixels. We can unpack this tuple into separate variables width and height.

Finally, we print the size of the image using the print() function.

Note that the PIL package may need to be installed separately using a package manager such as pip. Additionally, the image file must be in a format that is supported by PIL, such as JPEG, PNG, or GIF.