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

Skip to content

imread with URL string unit test #4485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove file name logic from pilread function
The Pillow docs state that Image.open can handle either a filename string or a
file object. That simplifies the pilread function substantially.
  • Loading branch information
rnelsonchem committed Apr 14, 2015
commit c5bc3013d8060f9fed34a2237bf08f9978cfb72b
17 changes: 2 additions & 15 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,21 +1227,8 @@ def pilread(fname):
from PIL import Image
except ImportError:
return None
if cbook.is_string_like(fname):
parsed = urlparse(fname)
# If the string is a URL, then download the data
if parsed.scheme is not '':
fh = BytesIO(urlopen(fname).read())
image = Image.open(fh)
return pil_to_array(image)
else:
# force close the file after reading the image
with open(fname, "rb") as fh:
image = Image.open(fh)
return pil_to_array(image)
else:
image = Image.open(fname)
return pil_to_array(image)
image = Image.open(fname)
return pil_to_array(image)

handlers = {'png': _png.read_png, }
if format is None:
Expand Down