JpegImageFile' object has no attribute 'shape' code example
Example: 'PngImageFile' object has no attribute 'shape'
The problem is that pimg is in PIL image format.
While imutils.resize function expects the image in Numpy array format.
So, after pimg = Image.open(b) line you need to convert the PIL image
to Numpy array like below:
pimg = np.array(pimg)