I'm reading a bunch of RGB images, one at a time, with different size using the PIL library and then convert them to numpy array. I use the following code and with 99% of the images I use, it works well.
from PIL import Image
import numpy as np
in_image = r'path\to\img_rgb.tif'
try:
in_img = Image.open(in_image)
in_array = np.array(in_img)
print(in_array.shape)
print(in_array)
except Exception as e:
print(e)
But some images are read by PIL, passed to numpy and the result is not an array and the shape is empty. There are no errors or exceptions raised.
I've opened an issue on numpy Github but it seems that the problem comes from PIL. Here's the link to it. There is also two test files attached to the issue.