Main Content

imfinfo

信息rmation about graphics file

Description

example

info= imfinfo(filename)returns a structure whose fields contain information about an image in a graphics file,filename.

The format of the file is inferred from its contents.

  • Iffilenameis a TIFF, PGM, PBM, PPM, HDF, ICO, GIF, SVS, or CUR file containing more than one image, theninfois 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 namedfilename.fmt, if MATLAB®cannot find a file namedfilename.

Examples

collapse all

Find information about the example image,ngc6543a.jpg.

信息= imfinfo ('ngc6543a.jpg');

Theinfostructure contains the following information fields:Filename,FileModDate,FileSize,Format,FormatVersion,Width,Height,BitDepth,ColorType,FormatSignature,NumberOfSamples,CodingMethod,CodingProcess, andComment.

To display information from the structure, for exampleCodingMethod, typeinfo.CodingMethodin the command window.

info.CodingMethod
ans = 'Huffman'

To display all the properties in the structure, typeinfoin the command window.

Input Arguments

collapse all

Name of graphics file, specified as a character vector or string scalar.

Depending on the location of the file,filenamecan take on one of these forms.

Location

Form

Current folder or folder on the MATLAB path

Specify the name of the file infilename.

Example:'myImage.jpg'

File in a folder

If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name.

Example:'C:\myFolder\myImage.ext'

Example:'\imgDir\myImage.ext'

URL

If the file is located by an internet URL, thenfilenamemust contain the protocol type such as,http://.

Example:'http://hostname/path_to_file/my_image.jpg'

Remote Location

If the file is stored at a remote location, thenfilename必须包含的完整路径的the file specified as a uniform resource locator (URL) of the form:

scheme_name://path_to_file/my_file.ext

Based on the remote location,scheme_namecan be one of the values in this table.

Remote Location scheme_name
Amazon S3™ s3
Windows Azure®Blob Storage wasb,wasbs
HDFS™ hdfs

For more information, seeWork with Remote Data.

Example:'s3://bucketname/path_to_file/my_image.jpg'

Data Types:char|string

Image format, specified as a character vector or string scalar. The possible values forfmtare contained in the MATLAB file format registry. To view of list of these formats, run theimformatscommand.

Example:'gif'

Data Types:char|string

Output Arguments

collapse all

信息rmation about the graphics file, returned as a structure array. The set of fields ininfodepends 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 character vector contains the full path name of the file.

character vector

FileModDate

Date when the file was last modified.

character vector

FileSize

Size of the file, in bytes.

integer

Format

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

character vector

FormatVersion

File format version.

character vector or number

Width

Image width, in pixels.

integer

Height

图像的高度,以像素为单位。

integer

BitDepth

Number of bits per pixel.

integer

ColorType

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

character vector

Additional fields returned by some file formats:

  • JPEG, DNG, and TIFF only— Iffilenamecontains Exchangeable Image File Format (EXIF) tags, theninfomight also contain'DigitalCamera'or'GPSInfo'(global positioning system information) fields.

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

  • JPEG2000 only— Theinfostructure 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.

  • DNG onlyimfinforeturns tags belonging to Adobe®DNG file versions 1.2 through 1.5 as individual named fields in the output structure. For a complete list of DNG file tags, see Chapter 4 of theAdobe Digital Negative (DNG) Specification.

提示

  • When you useimfinfoto get information about an Adobe DNG file, it returns the image dimensions of the preview image in the'Height'and'Width'fields of theinfostructure.

Version History

Introduced before R2006a

See Also

|||(Image Processing Toolbox)