Created
October 17, 2012 18:46
-
-
Save rsignell-usgs/3907322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import matplotlib.pyplot as plt | |
# 1. imread can load a PNG URL thusly... | |
url = 'http://optipng.sourceforge.net/pngtech/img/lena.png' | |
im = plt.imread(urllib2.urlopen(url),format='png') | |
plt.imshow(im) | |
# 2. same thing for JPG URL bombs... | |
url = 'http://www.kitware.com/blog/files/128_1232259669.jpg' | |
im = plt.imread(urllib2.urlopen(url),format='jpg') | |
plt.imshow(im) | |
# 3. yet imread can read JPG if downloaded first | |
urllib.urlretrieve(url,'lena.jpg') | |
im = plt.imread('lena.jpg') | |
plt.imshow(im,origin='lower') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment