function [X,map] = gifread(filename)
%GIFREAD Read a GIF (Graphics Interchange Format) file from disk.
%       [X,MAP]=GIFREAD('filename') reads the file 'filename' and returns
%       the indexed image X and associated colormap MAP.  If no extension
%       is given for the filename, the extension '.gif' is assumed.
%
%       See also: GIFWRITE, BMPREAD, HDFREAD, PCXREAD, TIFFREAD,
%                 XWDREAD.

%       Rick Paxson 07-28-93
%       Copyright (c) 1993 by The MathWorks, Inc.
%       $Revision: 1.16 $  $Date: 1993/10/05 14:14:05 $

if nargin ~= 1
  error('Requires one input argument.');
elseif nargin == 1 & isstr(filename)
  if (isempty(findstr(filename,'.'))==1)
	filename=[filename,'.gif'];
  end
  % Find full filename
  fid = fopen(filename);
  if fid == -1, error(['File ',filename' not found.']); end
  fname = fopen(fid); fclose(fid);
  [X,map] = ungif(fname);
  X = X + 1;
  X = X';
  map = map(1:max(max(X)),:);
end


