-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
What did you do?
I was trying to create an Image from a numpy array using Image.fromarray(array, mode) and validate the created image by using the show() function. It did not create the right image.
What did you expect to happen?
Show a white image
What actually happened?
Showed an image with seperated colors.
What are your OS, Python and Pillow versions?
- OS: Windows
- Python: 3.6.8
- Pillow: 7.2.0
What is the problem?
Pillow shows the right image if the dtype of the values in the array is uint8, but seems to have problems accepting other data types.
import numpy as np
from PIL import Image
array = np.full((32,32,3),255)
array[0].dtype
image = Image.fromarray(array, "RGB")
image.show()It does however work if I first convert the array to uint8:
import numpy as np
from PIL import Image
array = np.full((32,32,3),255)
array = np.uint8(array)
array[0].dtype
image = Image.fromarray(array, "RGB")
image.show()
