Skip to content

Commit

Permalink
Fixed #583 - Support strided numpy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
emcconville committed Jul 19, 2022
1 parent be40bfc commit 5e3ffb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changes.rst
Expand Up @@ -15,6 +15,7 @@ Version 0.6.9
Unreleased.

- Updated :meth:`Image.fx() <wand.image.BaseImage.fx>` method to raise :class:`~wand.exceptions.WandRuntimeError` if ImageMagick is unable to generate an image. [:issue:`582`]
- Fixed :meth:`Image.from_array() <wand.image.Image.from_array>` classmethod to handle Numpy's strided arrays. [:issue:`582`]


.. _changelog-0.6.8:
Expand Down
3 changes: 2 additions & 1 deletion wand/image.py
Expand Up @@ -9513,7 +9513,8 @@ def from_array(cls, array, channel_map=None, storage=None):
channel_map = 'CMYKA'[0:shape[2]]
else:
channel_map = 'R'
if hasattr(array, 'ctypes'):
strides = arr_itr.get('strides', None)
if hasattr(array, 'ctypes') and strides is None:
data_ptr = array.ctypes.data_as(ctypes.c_void_p)
elif hasattr(array, 'tobytes'):
data_ptr = array.tobytes()
Expand Down

0 comments on commit 5e3ffb3

Please sign in to comment.