|
66 | 66 | __all__ = ['bytescale', 'imread', 'imsave', 'fromimage', 'toimage', 'imresize']
|
67 | 67 |
|
68 | 68 |
|
| 69 | +PILLOW_ERROR_MESSAGE = ( |
| 70 | + "The Python Imaging Library (PIL) is required to load data " |
| 71 | + "from jpeg files. Please refer to " |
| 72 | + "https://pillow.readthedocs.io/en/stable/installation.html " |
| 73 | + "for installing PIL." |
| 74 | +) |
| 75 | + |
| 76 | + |
69 | 77 | def bytescale(data, cmin=None, cmax=None, high=255, low=0):
|
70 | 78 | """
|
71 | 79 | Byte scales an array (image).
|
@@ -194,8 +202,7 @@ def imread(name, flatten=False, mode=None):
|
194 | 202 |
|
195 | 203 | """
|
196 | 204 | if not pillow_installed:
|
197 |
| - raise ImportError("The Python Imaging Library (PIL) " |
198 |
| - "is required to load data from jpeg files") |
| 205 | + raise ImportError(PILLOW_ERROR_MESSAGE) |
199 | 206 |
|
200 | 207 | im = Image.open(name)
|
201 | 208 | return fromimage(im, flatten=flatten, mode=mode)
|
@@ -281,8 +288,7 @@ def fromimage(im, flatten=False, mode=None):
|
281 | 288 |
|
282 | 289 | """
|
283 | 290 | if not pillow_installed:
|
284 |
| - raise ImportError("The Python Imaging Library (PIL) " |
285 |
| - "is required to load data from jpeg files") |
| 291 | + raise ImportError(PILLOW_ERROR_MESSAGE) |
286 | 292 |
|
287 | 293 | if not Image.isImageType(im):
|
288 | 294 | raise TypeError("Input is not a PIL image.")
|
@@ -349,8 +355,7 @@ def toimage(arr, high=255, low=0, cmin=None, cmax=None, pal=None,
|
349 | 355 |
|
350 | 356 | """
|
351 | 357 | if not pillow_installed:
|
352 |
| - raise ImportError("The Python Imaging Library (PIL) " |
353 |
| - "is required to load data from jpeg files") |
| 358 | + raise ImportError(PILLOW_ERROR_MESSAGE) |
354 | 359 |
|
355 | 360 | data = asarray(arr)
|
356 | 361 | if iscomplexobj(data):
|
|
0 commit comments