Skip to content

plt.imshow() error on PIL-opened tiff images #12140

Closed

Description

@anntzer
plt.imshow(PIL.Image.open("lib/matplotlib/tests/baseline_images/test_image/uint16.tif"))

fails with

<elided>
  File "/home/antony/src/extern/matplotlib/lib/matplotlib/image.py", line 838, in make_image
    unsampled=unsampled)
  File "/home/antony/src/extern/matplotlib/lib/matplotlib/image.py", line 447, in _make_image
    if A.mask.shape == A.shape:
AttributeError: 'numpy.ndarray' object has no attribute 'mask'

since 12c27f3 (mpl 2.1 @tacaswell); previously it was possible to directly plot PIL-opened images (which do follow the standard buffer protocol).

It is not particularly problematic because one can just wrap explicitly the PIL-opened image using np.asarray, or use plt.imread instead (which does exactly that); still, I'm raising the issue here in case we want to fix it. (Or documenting that we no longer support PIL images is fine too, again the workaround is not that bad.)

Activity

  1. added this to the v2.2.4 milestone on Sep 17, 2018
  2. tacaswell commented on Sep 17, 2018

    @tacaswell
    Member

    that interpolation refactor is the bug that just keeps giving....

  3. modified the milestones: v2.2.4, v2.2.5 on Feb 11, 2019
  4. modified the milestones: v2.2.5, v2.2.4 on Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions