I do not know how to abort imread using a timer object. In addition, I suspect its capabilities. But I can recommend you check if you can access the file first and then get the file. I wrote the following function to check the status of a file and the Internet:
function flag = does_url_exist(urlName) url =java.net.URL(urlName); try link = openStream(url); parse = java.io.InputStreamReader(link); snip = java.io.BufferedReader(parse); if ~isempty(snip) flag = 1; else flag = 0; end catch exception flag = 0; end end
Then it looks like this:
fname = 'http://www.hollywoodheadache.com/wp-content/uploads/2007/12/tom-and-julia.jpg'; if(does_url_exist(fname)) img = imread(fname); end
Please note that to check the Internet connection, I took the source code for this post . Also note that if you are sure that the file exists, it is impossible to verify it again, since it increases the operating time.
source share