function [N,s]=imginfo(ifn,fext,infofn)
% imginfo Extract information from image files 
% Usage: [Nimg info]=imginfo(filename,['type']). 
%
% Nimg is the number of images in the file.  info is a structure will all
% information from the file.  File type is determined by file extension by
% default or by optional 'type' input.
%
% Supported types: 
% .bin  Basler raw files
% .img  dalsa raw files
% .cin  phantom raw files

% revision history:
% 04/19/96 Mark D. Shattuck <mds> dalinfo.m  
% 12/22/97 Added force type
% 01/28/98 Removed different dalsa types put into one file created imginfo
%          wrapper to parse types; added xillex type
% 06/14/01 Removed xillex type.
% 09/24/02 Added basler type.
% 09/04/07 Added phantom type.

if(~exist('fext','var')||isempty(fext))
  [~,~,fext]=fileparts(ifn); 
end

if(~exist('infofn','var'))
  infofn=[]; 
end

if(~exist(ifn,'file'))
  fprintf('File %s does not exist!\n',fext);    % Check for File
  N=-99;
  s=0;
  return
end

if(strcmpi(fext,'.bin'))
  [N s]=baslerinfo(ifn,infofn);     % get file info
elseif(strcmpi(fext,'.img'))
  [N s]=dalinfo(ifn);     % get file info
elseif(strcmpi(fext,'.cin'))
  [N s]=cininfo(ifn);     % get file info
else
  fprintf('File format %s is not supported\n',fext);    % Check for File
  N=-1;
  s=0;
  return
end
