]> Creatis software - CreaPhase.git/blob - octave_packages/image-1.0.15/imginfo.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / image-1.0.15 / imginfo.m
1 ## Copyright (C) 2002 Etienne Grossmann.  All rights reserved.
2 ##
3 ## This program is free software; you can redistribute it and/or modify it
4 ## under the terms of the GNU General Public License as published by the
5 ## Free Software Foundation; either version 2, or (at your option) any
6 ## later version.
7 ##
8 ## This is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11 ## for more details.
12 ##
13
14 ## -*- texinfo -*-
15 ## @deftypefn {Function File} {@var{hw} =} imginfo (@var{filename})
16 ## @deftypefnx{Function File} {[@var{h}, @var{w}] =} imginfo (@var{filename})
17 ## Get image size from file @var{filename}.
18 ##
19 ## The output is the size of the image
20 ## @table @code
21 ## @item @var{h}
22 ## Height of image, in pixels.
23 ## @item @var{w}
24 ## Width  of image, in pixels.
25 ## @item @var{hw} = [@var{h}, @var{w}]
26 ## Height and width of image.
27 ## @end table
28 ##
29 ## NOTE : imginfo relies on the 'convert' program.
30 ## @end deftypefn
31
32 ## Author:        Etienne Grossmann <etienne@cs.uky.edu>
33 ## Last modified: Setembro 2002
34
35 function [h,w] = imginfo (fn)
36
37 warning ("'imginfo' has been deprecated in favor of 'imfinfo'. This function will be removed from future versions of the 'image' package");
38        
39 [status, res] = system(sprintf("convert -verbose '%s' /dev/null",fn),1);
40
41 if status,
42   error (["imginfo : 'convert' exited with status %i ",\
43           "and produced\n%s\n"],\
44          status, res);
45 end
46
47 res = res(index(res," ")+1:length(res));
48
49 i = index (res,"x");
50 if ! i, error ("imginfo : Can't interpret string (i)\n%s\n", res); end
51
52 j = index (res(i-1:-1:1)," ");
53 if j<2, error ("imginfo : Can't interpret string (j)\n%s\n", res); end
54 w = str2num (res(i-j:i-1));
55
56 k = index (res(i+1:length(res))," ");
57 if k<2, error ("imginfo : Can't interpret string (k)\n%s\n", res); end
58 h = str2num (res(i+1:i+k));
59
60 if nargout<2, h = [h,w]; end