From af979830020506d994888f676dd71b547abaab89 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 24 Jun 2019 19:32:00 +0930
Subject: [PATCH] RF: Make Pillow conditional

---
 fsl/data/bitmap.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fsl/data/bitmap.py b/fsl/data/bitmap.py
index c7d172c25..ec7b6b1fe 100644
--- a/fsl/data/bitmap.py
+++ b/fsl/data/bitmap.py
@@ -5,7 +5,7 @@
 # Author: Paul McCarthy <pauldmccarthy@gmail.com>
 #
 """This module contains the :class:`Bitmap` class, for loading bitmap image
-files.
+files. Pillow is required to use the ``Bitmap`` class.
 """
 
 
@@ -14,7 +14,6 @@ import                 logging
 import                 six
 
 import numpy        as np
-import PIL.Image    as Image
 
 from . import image as fslimage
 
@@ -52,6 +51,11 @@ class Bitmap(object):
                   data.
         """
 
+        try:
+            import PIL.Image as Image
+        except ImportError:
+            raise RuntimeError('Install Pillow to use the Bitmap class')
+
         if isinstance(bmp, six.string_types):
             source = bmp
             data   = np.array(Image.open(source))
-- 
GitLab