-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
These modifications allow valid URL strings to be passed directly into imread. URL recognition is done using the standard library function urlparse. If the string contains a valid url scheme, it will be used to download and process the data using a combination of urlopen and BytesIO (StringIO in python 2).
The Pillow docs state that Image.open can handle either a filename string or a file object. That simplifies the pilread function substantially.
It seems that the identity test for the parsed URL scheme was not sufficient. I changed this to an equality test, and things are now working properly.
Also added the logo2.png file to the test image folder. If there is a URLError, imread will simply open the local file and print a little error.
@tacaswell I tried to add the test case as a new branch at the end of my original PR. But now it looks like this brought in all of the commits from my other branch as well. I hope this is okay. If not, could you provide some guidance on how to fix this. |
Just leave it, github is very clever and this will look better once the other PR is merged. |
Anything holding up this PR? |
The hold up on this is ensuring that adding a test that touches the internet is kosher with debian packaging rules. |
Could we perhaps use |
Replaced by #10817. |
This PR adds a test case to #4256. At this point, it may need some careful thought because it pulls an image down from the internet. This may be a violation of Debian's packaging rules. See #4256 for more discussion.