![]() |
VOOZH | about |
Let us see how to find the resolution of an image in Python. We will be solving this problem with two different libraries which are present in Python:
In our examples we will be using the following image:
👁 ImageThe resolution of the above image is 600x135.
We will be using a library named Pillow to find the size(resolution) of the image. We will be using the function PIL.Image.open() to open and read our image and store the size in two variables by using the function img.size.
Output:
600x135
We will import OpenCV by importing the library cv2. We will load the image using the cv2.imread() function. After this, the dimensions can be found using the shape attribute. shape[0] will give us the height and shape[1] will give us the width.
Output:
600x135