-
|
I'm updating some old code and noticed a new failure that I'm really surprised ever worked in the first place. import numpy as np
from PIL import Image
data = np.zeros((1, 1, 3))
img = Image.fromarray(data, mode="rgb")With older pre-12.0 versions of PIL this magically worked. If you look at the properties,
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I'm not able to replicate this. With 11.3.0, I receive Traceback (most recent call last):
File "demo.py", line 6, in <module>
img = Image.fromarray(data, mode="rgb")
File "PIL/Image.py", line 3336, in fromarray
return frombuffer(mode, size, obj, "raw", rawmode, 0, 1)
File "PIL/Image.py", line 3225, in frombuffer
return frombytes(mode, size, data, decoder_name, args)
File "PIL/Image.py", line 3152, in frombytes
im = new(mode, size)
File "PIL/Image.py", line 3117, in new
return im._new(core.fill(mode, size, color))
ValueError: unrecognized image modeBut I do receive a different error with Pillow 12. Traceback (most recent call last):
File "PIL/Image.py", line 3285, in fromarray
typemode, rawmode, color_modes = _fromarray_typemap[typekey]
KeyError: ((1, 1, 3), '<f8')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "demo.py", line 6, in <module>
img = Image.fromarray(data, mode="rgb")
File "PIL/Image.py", line 3289, in fromarray
raise TypeError(msg) from e
TypeError: Cannot handle this data type: (1, 1, 3), <f8 |
Beta Was this translation helpful? Give feedback.
-
|
Thanks. Previously, the You have seen that there is a deprecation for some So there should be two scenarios that currently work, but are deprecated.
Unintentionally, during that rollback, I dropped support for the first scenario. It should be deprecated, but still work, but now it just doesn't work. Now that it is out there though, I'm not convinced that we should bring back the deprecation? It seems odd to make Pillow 12.1.0 work, only to take the fuctionality away again when the deprecation ends in Pillow 13 in October 2026. Feel free to offer your thoughts. |
Beta Was this translation helpful? Give feedback.
"rgb" was reported as an "unrecognized image mode". That makes sense to me. If you look at the list of Pillow modes, you will see that we have both RGBA and RGBa, along with LA and La. This means that we can't handle all mode names case insensitively.
The behaviour has been present since Pillow forked from PIL. I don't think of features as being more or less supported, so I'm not sure what you mean. Within an issue talking about interpreting float NumPy data as integers, there was the following comment - #5465 (comment)