MATLAB Function Reference    

Information about graphics file



info = imfinfo(filename,fmt) returns a structure, info, whose fields contain information about an image in a graphics file. filename is a string that specifies the name of the graphics file, and fmt is a string that specifies the format of the file. The file must be in the current directory or in a directory on the MATLAB path. If imfinfo cannot find a file named filename, it looks for a file named filename.fmt.

This table lists all the possible values for fmt.

File Type
Windows Bitmap (BMP)
Windows Cursor resources (CUR)
Graphics Interchange Format (GIF)
Hierarchical Data Format (HDF)
Windows Icon resources (ICO)
'jpg' or 'jpeg'
Joint Photographic Experts Group (JPEG)
Portable Bitmap (PBM)
Windows Paintbrush (PCX)
Portable Graymap (PGM)
Portable Network Graphics (PNG)
Portable Pixmap (PPM)
Sun Raster (RAS)
'tif' or 'tiff'
Tagged Image File Format (TIFF)
X Windows Dump (XWD)

If filename is a TIFF, HDF, ICO, GIF, or CUR file containing more than one image, info is a structure array with one element (i.e., an individual structure) for each image in the file. For example, info(3) would contain information about the third image in the file.

info = imfinfo(filename) attempts to infer the format of the file from its contents.

Information Returned

The set of fields in info depends on the individual file and its format. However, the first nine fields are always the same. This table lists these common fields and describes their values.

A string containing the name of the file; if the file is not in the current directory, the string contains the full pathname of the file
A string containing the date when the file was last modified
An integer indicating the size of the file in bytes
A string containing the file format, as specified by fmt; for JPEG and TIFF files, the three-letter variant is returned
A string or number describing the version of the format
An integer indicating the width of the image in pixels
An integer indicating the height of the image in pixels
An integer indicating the number of bits per pixel
A string indicating the type of image; either 'truecolor' for a truecolor RGB image, 'grayscale' for a grayscale intensity image, or 'indexed' for an indexed image


See Also

imformats, imread, imwrite

Bit-Mapped Images for related functions

  imagesc imformats