Skip to content

Commit a697bd0

Browse files
committed
Merge pull request #194 from caspervdw/fix-plot-to-frame
FIX Image import in plot_to_frame
2 parents 93f88fe + 27058ff commit a697bd0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pims/display.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ def plot_to_frame(fig, dpi, **imsave_kwargs):
391391
pims.Frame object containing RGBA values (dtype uint8)
392392
"""
393393
if mpl is None:
394-
raise ImportError('Module matplotlib not found')
394+
raise ImportError("This feature requires matplotlib.")
395+
try:
396+
from PIL import Image
397+
except ImportError:
398+
raise ImportError("This feature requires PIL/Pillow.")
395399
from pims import Frame
396400
buffer = six.BytesIO()
397401
if isinstance(fig, mpl.axes.Axes):
@@ -419,7 +423,7 @@ def plots_to_frame(figures, width=512, close_fig=False, **imsave_kwargs):
419423
pims.Frame object containing a stack of RGBA values (dtype uint8)
420424
"""
421425
if mpl is None:
422-
raise ImportError('Module matplotlib not found')
426+
raise ImportError("This feature requires matplotlib.")
423427
from pims import Frame
424428
if 'dpi' in imsave_kwargs or 'format' in imsave_kwargs:
425429
raise ValueError('Do not specify dpi or format imsave kwargs.')

0 commit comments

Comments
 (0)