From 8e0bf8ab8fc4a2a1b52a4f1b7825da960c430e72 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 20 Apr 2013 14:57:58 -0500 Subject: [PATCH] Fix imread from urls on some backends. Some backends infer the image type from the extension. This fix just adds the extension to the temp filename. --- skimage/io/_io.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skimage/io/_io.py b/skimage/io/_io.py index f8f395bd..5dfe107b 100644 --- a/skimage/io/_io.py +++ b/skimage/io/_io.py @@ -130,7 +130,8 @@ def imread(fname, as_grey=False, plugin=None, flatten=None, as_grey = flatten if is_url(fname): - with tempfile.NamedTemporaryFile(delete=False) as f: + _, ext = os.path.splitext(fname) + with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as f: u = urllib2.urlopen(fname) f.write(u.read()) img = call_plugin('imread', f.name, plugin=plugin, **plugin_args)