Documentation

imfinfo

Information about graphics file

Syntax

  • info = imfinfo(filename) example
  • info = imfinfo(filename,fmt)
  • info = imfinfo(URL)

Description

example

info = imfinfo(filename) returns a structure whose fields contain information about an image in a graphics file, filename. The file must be in the current folder or in a folder on the MATLAB® path.

The format of the file is inferred from its contents.

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

info = imfinfo(filename,fmt) additionally looks for a file named filename.fmt, if MATLAB cannot find a file named filename.

info = imfinfo(URL) returns information about the image at the specified Internet resource, URL.

Examples

expand all

Return Information About Graphics File

Find information about the example image, ngc6543a.jpg.

info = imfinfo('ngc6543a.jpg')
info = 

           Filename: 'matlabroot\toolbox\matlab\demos\ngc6543a.jpg'
        FileModDate: '01-Oct-1996 16:19:44'
           FileSize: 27387
             Format: 'jpg'
      FormatVersion: ''
              Width: 600
             Height: 650
           BitDepth: 24
          ColorType: 'truecolor'
    FormatSignature: ''
    NumberOfSamples: 3
       CodingMethod: 'Huffman'
      CodingProcess: 'Sequential'
            Comment: {'CREATOR: XV Version 3.00b  Rev: 6/15/94  Quality = 75, Smoothing = 0
'}

Input Arguments

expand all

filename — Name of graphics filestring

Name of graphics file, specified as a string.

Example: 'myImage.jpg'

Data Types: char

fmt — Image formatstring

Image format, specified as a string. The possible values for fmt are contained in the MATLAB file format registry. To view of list of these formats, run the imformats command.

Example: 'gif'

Data Types: char

URL — Image locationstring

Image location, specified as a string. URL must include the protocol type (e.g., http://).

Data Types: char

Output Arguments

expand all

info — Information about graphics filestructure array

Information about the graphics file, returned as a structure array. The set of fields in info depends on the individual file and its format. This table lists the nine fields that always appear, and describes their values.

Field Name

Description

Value

Filename

Name of the file or the Internet URL specified. If the file is not in the current folder, the string contains the full path name of the file.

string

FileModDate

Date when the file was last modified.

string

FileSize

Size of the file, in bytes.

integer

Format

File format, as specified by fmt. For formats with more than one possible extension (for example, JPEG and TIFF files), imfinfo returns the first variant in the file format registry.

string

FormatVersion

File format version.

string or number

Width

Image width, in pixels.

integer

Height

Image height, in pixels.

integer

BitDepth

Number of bits per pixel.

integer

ColorType

Image type. ColorType includes, but is not limited to, 'truecolor' for a truecolor (RGB) image, 'grayscale' for a grayscale intensity image, or 'indexed' for an indexed image.

string

Additional fields returned by some file formats:

  • JPEG and TIFF only — If filename contains Exchangeable Image File Format (EXIF) tags, then info might also contain 'DigitalCamera' or 'GPSInfo' (global positioning system information) fields.

  • GIF onlyimfinfo returns the value of the 'DelayTime' field in hundredths of seconds.

  • JPEG2000 only — The info structure contains an m-by-3 cell array, 'ChannelDefinition'. The first column of 'ChannelDefinition' reports a channel position as it exists in the file. The second column reports the type of channel, and the third column reports the channel mapping.

See Also

| |

Was this topic helpful?