FUNCTION REFERENCE
imfinfo
Information about an image file.
Information about an image file.
Syntax
info = imfinfo(filename)Syntax
info = imfinfo(filename, fmt)Every format gives Filename, FileModDate, FileSize, Format ('png', 'jpg', 'bmp' or 'tif'), FormatVersion, Width, Height, BitDepth (bits per pixel over all samples), ColorType ('grayscale', 'truecolor' or 'indexed') and FormatSignature. PNG adds MATLAB's PNG field set (Colormap, InterlaceType, Transparency, text fields, ...; [] when absent); JPEG adds NumberOfSamples, CodingMethod, CodingProcess and Comment; BMP adds NumColormapEntries, Colormap and CompressionType; TIFF adds ByteOrder, BitsPerSample and SamplesPerPixel. Headers are read directly, so imfinfo works in every build.
GIF gives a K-by-1 struct array, one element per frame (reading is bounded by 256 MiB), with Format 'GIF', FormatVersion ('89a' or '87a'), Width and Height of the logical screen, BitDepth (bits of the frame's colour table), ColorType 'indexed', FormatSignature, BackgroundColor and TransparentColor (one-based indices, [] when absent), AspectRatio, ColorTable, Interlaced ('yes' or 'no'), DelayTime (hundredths of a second), DisposalMethod, LoopCount (on every element: Inf for loop forever, [] when the file has no loop block) and Left and Top (one-based).
Example
f=[tempname(pwd) '.png']; imwrite(uint8(magic(4)), f); i=imfinfo(f); delete(f); i.ColorType % grayscaleExample
f=[tempname(pwd) '.gif']; imwrite(uint8([0 1]), [0 0 0; 1 1 1], f, 'DelayTime', 0.25); imwrite(uint8([1 0]), [0 0 0; 1 1 1], f, 'WriteMode', 'append', 'DelayTime', 0.5); i=imfinfo(f); delete(f); [i.DelayTime] % [25 50]Differences from MATLAB: BMP and TIFF return the subset of fields listed above (MATLAB has many more, for TIFF one struct per page); GIF returns the fields listed above (MATLAB also reports comment and other extension data); PBM, PCX and the other formats are not supported yet.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.