# Program 9: Read an image and identify its shape using Python
# The "shape" of an image is its size as an array of numbers:
# height (rows of pixels) x width (columns of pixels) x colour channels.

import cv2

image = cv2.imread("photo.jpg")
print("Shape of the colour image :", image.shape)

height, width, channels = image.shape
print("Height   :", height, "pixels")
print("Width    :", width, "pixels")
print("Channels :", channels, "(Blue, Green, Red)")
print("Total pixels         :", height * width)
print("Total numbers stored :", image.size)
print()

grey = cv2.imread("photo.jpg", cv2.IMREAD_GRAYSCALE)
print("Shape of the grayscale image :", grey.shape)
print("A grayscale image has no third number: one value per pixel.")
print()

if height > width:
    print("This image is in portrait shape (taller than wide).")
elif width > height:
    print("This image is in landscape shape (wider than tall).")
else:
    print("This image is square.")
