Mercurial > octave-nkf
diff scripts/image/private/__imread__.m @ 18298:15db54c4a572
Fix input parsing for imageIO functions and make imread accept URL (bug #41234)
* image/private/imageIO.m: make this function check existence of the file
and handle URLs. It may also modify the input that imread() and imfinfo()
received to remove the format name if it was given as a separate argument. The
filepath will be modified to give the absolute filepath, and URLs will cause
the file to be downloaded, and the filepath for a temporary will be given (and
the file removed in the end). If the file can't be found it will thrown an error
meaning that if the file is not found, whatever function is set for that format,
it will never be called).
* image/imfinfo.m, image/imread.m: change functions for the modified call to
imageIO() and add new tests.
* image/private/__imfinfo__.m, image/private/__imread__.m: remove parsing of
input, checking for existence of file, and handling of URL since that is now
done by imageIO().
* image/imformats.m: fix tests for the new behaviour.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Thu, 16 Jan 2014 19:12:36 +0000 |
parents | b5970988ccff |
children | 4197fc428c7d |
line wrap: on
line diff
--- a/scripts/image/private/__imread__.m Fri Jan 17 19:09:42 2014 +0000 +++ b/scripts/image/private/__imread__.m Thu Jan 16 19:12:36 2014 +0000 @@ -44,18 +44,6 @@ ## keep track of the varargin offset we're looking at each moment offset = 1; - filename = tilde_expand (filename); - fn = file_in_path (IMAGE_PATH, filename); - if (isempty (fn) && nargin >= offset + 1 && ischar (varargin{offset})) - ## if we can't find the file, check if the next input is the file extension - filename = [filename "." varargin{offset}]; - fn = file_in_path (IMAGE_PATH, filename); - offset++; - endif - if (isempty (fn)) - error ("imread: cannot find %s", filename); - endif - ## It is possible for an file with multiple pages to have very different ## images on each page. Specifically, they may have different sizes. Because ## of this, we need to first find out the index of the images to read so @@ -92,9 +80,9 @@ ## Use information from the first image to be read to set defaults. if (ischar (options.index) && strcmpi (options.index, "all")) - info = __magick_ping__ (fn, 1); + info = __magick_ping__ (filename, 1); else - info = __magick_ping__ (fn, options.index(1)); + info = __magick_ping__ (filename, options.index(1)); endif ## Set default for options. @@ -145,7 +133,7 @@ endswitch endfor - [varargout{1:nargout}] = __magick_read__ (fn, options); + [varargout{1:nargout}] = __magick_read__ (filename, options); endfunction