-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_8bit_with_16bit_depth fails on s390x (64 bit/big endian machine) #1016
Comments
I can reproduce the exception on an amd64 architecture using the following snippet: >>> import imageio.v3 as iio
>>> import numpy as np
>>> img = iio.imread("imageio:chelsea.png", mode="L")
>>> img.dtype
dtype('uint8')
>>> iio.imwrite("foo.png", img.astype("<u2"))
>>> iio.imwrite("foo.png", img.astype(">u2"))
Traceback (most recent call last):
File "/Users/<user>/projects/imageio/.venv/lib/python3.10/site-packages/PIL/PngImagePlugin.py", line 1277, in _save
rawmode, mode = _OUTMODES[mode]
KeyError: 'I;16B'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/<user>/projects/imageio/imageio/v3.py", line 139, in imwrite
with imopen(
File "/Users/<user>/projects/imageio/imageio/core/v3_plugin_api.py", line 367, in __exit__
self.close()
File "/Users/<user>/projects/imageio/imageio/plugins/pillow.py", line 123, in close
self._flush_writer()
File "/Users/<user>/projects/imageio/imageio/plugins/pillow.py", line 457, in _flush_writer
primary_image.save(self._request.get_file(), **self.save_args)
File "/Users/<user>/projects/imageio/.venv/lib/python3.10/site-packages/PIL/Image.py", line 2413, in save
save_handler(self, fp, filename)
File "/Users/<user>/projects/imageio/.venv/lib/python3.10/site-packages/PIL/PngImagePlugin.py", line 1280, in _save
raise OSError(msg) from e
OSError: cannot write mode I;16B as PNG This originates from Pillow. Internally their PNG writer maintains a list of valid input buffer dtypes and The reason this error shows up on s390x is because it is a big-endian architecture. For PNGs (though this will likely extend in the future) ImageIO will unpack pixels into native endianness. As such you get a big-endian buffer on a big-endian machine, which is more performant but, for now, not allowed as input when writing with pillow. |
When running the tests on a s390x Debian machine, I get the following failure:
This is imageio 2.31.1 with PIL 9.5.0.
The text was updated successfully, but these errors were encountered: