Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9302392

Browse files
committed
Document use of Pillow as alternative.
1 parent 1e12cad commit 9302392

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
``imread()`` reading from URLs
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
Passing a URL to `~.pyplot.imread()` is deprecated. Please open the URL before
5-
reading using ``urllib.request.urlopen()``.
4+
Passing a URL to `~.pyplot.imread()` is deprecated. Please open the URL for
5+
reading and directly use the Pillow API
6+
(``PIL.Image.open(urllib.request.urlopen(url))``, or
7+
``PIL.Image.open(io.BytesIO(requests.get(url).content))``) instead.

lib/matplotlib/image.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,8 +1431,9 @@ def imread(fname, format=None):
14311431
The image file to read: a filename, a URL or a file-like object opened
14321432
in read-binary mode.
14331433
1434-
Passing a URL is deprecated. Please open the URL before reading using
1435-
``urllib.request.urlopen()``.
1434+
Passing a URL is deprecated. Please open the URL
1435+
for reading and pass the result to Pillow, e.g. with
1436+
``PIL.Image.open(urllib.request.urlopen(url))``.
14361437
format : str, optional
14371438
The image file format assumed for reading the data. If not
14381439
given, the format is deduced from the filename. If nothing can
@@ -1479,8 +1480,9 @@ def imread(fname, format=None):
14791480
if len(parsed.scheme) > 1: # Pillow doesn't handle URLs directly.
14801481
cbook.warn_deprecated(
14811482
"3.4", message="Directly reading images from URLs is "
1482-
"deprecated. Please open the URL before "
1483-
"reading using urllib.request.urlopen().")
1483+
"deprecated. Please open the URL for reading and pass the "
1484+
"result to Pillow, e.g. with "
1485+
"``PIL.Image.open(urllib.request.urlopen(url))``.")
14841486
# hide imports to speed initial import on systems with slow linkers
14851487
from urllib import request
14861488
ssl_ctx = mpl._get_ssl_context()

0 commit comments

Comments
 (0)