np.array(im) is height × width × channels. Image.fromarray goes back. dtype uint8.
Goal
Print shape and rebuild the image.
from PIL import Image
import numpy as np
im = Image.new('RGB', (40, 20), (255, 200, 0))
arr = np.array(im)
print(arr.shape, arr.dtype, arr[0, 0])from PIL import Image
import numpy as np
arr = np.zeros((30, 50, 3), dtype=np.uint8)
arr[:, :25] = (0, 128, 64)
im = Image.fromarray(arr)
print(im.size)
plt.imshow(im)
plt.axis('off')
plt.show()from PIL import Image
import numpy as np
im = Image.fromarray(np.arange(64, dtype=np.uint8).reshape(8, 8))
print(im.mode, im.size)import numpy as np
print(np.array([1, 2, 3], dtype=np.uint8))