import cv2
img = cv2.imread('/home/img/python.png', cv2.IMREAD_UNCHANGED)
dimensions = img.shape
height = img.shape[0]
width = img.shape[1]
channels = img.shape[2]
print('Image Dimension : ',dimensions)
print('Image Height : ',height)
print('Image Width : ',width)
print('Number of Channels : ',channels)
for the amount of channels you need to do
channels = image.shape[-1] if image.ndim == 3 else 1
This is because the amount of channels will not be shown if it is grayscale. And that is why image.ndim is checked.
To get width and height just do what you already did in your example
And for dimensions you could do:
dimensions = f"{width}x{height}"
if you want it to return in a string. Otherwise, if you want it to return as a tuple it will just be the first 2 objects in img.shape.