File tree 2 files changed +10
-6
lines changed
doc/api/next_api_changes/deprecations
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
``imread() `` reading from URLs
2
2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
3
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.
Original file line number Diff line number Diff line change @@ -1431,8 +1431,9 @@ def imread(fname, format=None):
1431
1431
The image file to read: a filename, a URL or a file-like object opened
1432
1432
in read-binary mode.
1433
1433
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))``.
1436
1437
format : str, optional
1437
1438
The image file format assumed for reading the data. If not
1438
1439
given, the format is deduced from the filename. If nothing can
@@ -1479,8 +1480,9 @@ def imread(fname, format=None):
1479
1480
if len (parsed .scheme ) > 1 : # Pillow doesn't handle URLs directly.
1480
1481
cbook .warn_deprecated (
1481
1482
"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))``." )
1484
1486
# hide imports to speed initial import on systems with slow linkers
1485
1487
from urllib import request
1486
1488
ssl_ctx = mpl ._get_ssl_context ()
You can’t perform that action at this time.
0 commit comments