function [N,s]=dalinfo(fn)
% Extract size and original head and tail information
% [Nimg info]=dalinfo(filename). info is a structure.

s.fdesc=dir(fn);

if (isempty(s.fdesc))
  disp('File does not exist!');
  return
end


s.MINPIXVAL=0;
s.MAXPIXVAL=255;
s.id='0000';
s.head=0;
s.ihead=0;
N=-1;

% parse filename
[s.path,s.fn,s.ext,s.versn]=fileparts(fn);
if(isempty(s.path))
  s.path=pwd;
end
s.fullname=fullfile(s.path,[s.fn s.ext s.versn]);
s.base=s.fn;
s.rfn=sprintf('%s',s.base);
if(~strcmp(s.fn,s.rfn))
  warning('Problem parsing filename.\nReconstructed filename=%s ~= original filename=%s.',s.rfn,s.fn);
end

s.infofn=sprintf('%s\\%s_info.tif',s.path,s.base);
s.idesc=dir(s.infofn);


if (isempty(s.idesc))
  disp('Info file does not exist!');
  return
end

s.info=imfinfo(s.infofn);

s.Ny=s.info.Width;
s.Nx=s.info.Height;
s.idsize=0;

s.imgsize=s.Nx*s.Ny;
  
N=(s.fdesc.bytes-s.idsize)/s.imgsize;
s.N=N;
  
if (N~=fix(N))
  disp('File length not multiple of imgsize');
  return
end
  
