From 9adcd89883019e69ed6d8204a9e46ead6f587a73 Mon Sep 17 00:00:00 2001 From: hawkerpl Date: Sat, 2 May 2015 16:09:41 +0200 Subject: [PATCH] fix more informative error while reading image --- skimage/io/_plugins/pil_plugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skimage/io/_plugins/pil_plugin.py b/skimage/io/_plugins/pil_plugin.py index 2e45cfd7..6fecbc2a 100644 --- a/skimage/io/_plugins/pil_plugin.py +++ b/skimage/io/_plugins/pil_plugin.py @@ -47,9 +47,13 @@ def imread(fname, dtype=None, img_num=None, **kwargs): try: # this will raise an IOError if the file is not readable im.getdata()[0] - except IOError: + except IOError as e: site = "http://pillow.readthedocs.org/en/latest/installation.html#external-libraries" - raise ValueError('Could not load "%s"\nPlease see documentation at: %s' % (fname, site)) + pillow_error_message = str(e) + error_message = ('Could not load "%s" \n' + 'Reason: "%s"\n' + 'Please see documentation at: %s') % (fname, pillow_error_message, site) + raise ValueError(error_message) else: return pil_to_ndarray(im, dtype=dtype, img_num=img_num)