File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 9
9
from numbers import Number
10
10
from pathlib import Path
11
11
import urllib .parse
12
+ import urllib .request
13
+ from io import BytesIO
12
14
13
15
import numpy as np
14
16
import PIL .PngImagePlugin
@@ -1470,9 +1472,8 @@ def imread(fname, format=None):
1470
1472
if isinstance (fname , str ):
1471
1473
parsed = urllib .parse .urlparse (fname )
1472
1474
if len (parsed .scheme ) > 1 : # Pillow doesn't handle URLs directly.
1473
- from urllib import request
1474
1475
with urllib .request .urlopen (fname ) as response :
1475
- return imread (response , format = ext )
1476
+ return imread (BytesIO ( response . read ()) , format = ext )
1476
1477
with img_open (fname ) as image :
1477
1478
return (_pil_png_to_float_array (image )
1478
1479
if isinstance (image , PIL .PngImagePlugin .PngImageFile ) else
Original file line number Diff line number Diff line change @@ -1118,3 +1118,9 @@ def test_exact_vmin():
1118
1118
1119
1119
# check than the RBGA values are the same
1120
1120
assert np .all (from_image == direct_computation )
1121
+
1122
+
1123
+ @pytest .mark .network
1124
+ @pytest .mark .flaky
1125
+ def test_https_imread_smoketest ():
1126
+ v = mimage .imread ('https://matplotlib.org/1.5.0/_static/logo2.png' )
You can’t perform that action at this time.
0 commit comments