From 9f7a376e4dcf19886c6f7f9cea806ffafc8bf36d Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Fri, 19 Oct 2012 15:21:31 -0400 Subject: [PATCH] ENH: Add test and support for reading file URLs --- skimage/io/_io.py | 2 +- skimage/io/tests/test_io.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/skimage/io/_io.py b/skimage/io/_io.py index bf75cf76..6986cc0f 100644 --- a/skimage/io/_io.py +++ b/skimage/io/_io.py @@ -16,7 +16,7 @@ from skimage.color import rgb2grey # Shared image queue _image_stack = [] -URL_REGEX = re.compile(r'http://|https://|ftp://') +URL_REGEX = re.compile(r'http://|https://|ftp://|file://') def is_url(filename): diff --git a/skimage/io/tests/test_io.py b/skimage/io/tests/test_io.py index 72f8496a..b29994c5 100644 --- a/skimage/io/tests/test_io.py +++ b/skimage/io/tests/test_io.py @@ -2,6 +2,7 @@ from numpy.testing import * import numpy as np import skimage.io as io +from skimage import data_dir def test_stack_basic(): @@ -15,5 +16,12 @@ def test_stack_basic(): def test_stack_non_array(): io.push([[1, 2, 3]]) + +def test_imread_url(): + image_url = 'file://%s/camera.png' % data_dir + image = io.imread(image_url) + assert image.shape == (512, 512) + + if __name__ == "__main__": run_module_suite()