I have to write a test case in python to check whether a jpg image is in color or grayscale. Can anyone please let me know if there is any way to do it with out installing e
There is more pythonic way using numpy functionality and opencv:
import cv2 def isgray(imgpath): img = cv2.imread(imgpath) if len(img.shape) < 3: return True if img.shape[2] == 1: return True b,g,r = img[:,:,0], img[:,:,1], img[:,:,2] if (b==g).all() and (b==r).all(): return True return False