Main Content

getTag

Value of specified tag

Description

tagValue = getTag(t,tagID) retrieves the value of the tag specified by tagID from the TIFF file associated with the Tiff object t.

example

Examples

collapse all

Open a TIFF file and get the value of its tags in multiple ways.

Create a Tiff object for the file.

t = Tiff('example.tif','r');

Get the tag value for the ImageWidth tag by specifying the tag by its name.

tagval = getTag(t,'ImageWidth')
tagval = 
600

Alternatively, specify the tag by its numeric identifier.

tagval1 = getTag(t,256)
tagval1 = 
600

Another way to specify the tag is to use the Tiff.TagID structure. The names of the fields of the Tiff.TagID structure are valid tag names that contain the corresponding tag numeric identifiers. For instance the field Tiff.TagID.ImageWidth contains the value 256.

tagval2 = getTag(t,Tiff.TagID.ImageWidth)
tagval2 = 
600

Close the Tiff object.

close(t);

Input Arguments

collapse all

Tiff object representing a TIFF file. Use the Tiff function to create the object.

Tag ID of a Tiff object, specified as a character vector or string scalar, or a numeric identifier.

For example, you can specify tagId for the ImageWidth tag as any of these:

  • Character vector or string scalar containing the tag name 'ImageWidth'

  • Numeric identifier 256 for the ImageWidth tag defined by the TIFF specification

  • Field of the Tiff.TagID structure Tiff.TagID.ImageWidth.

The names of the fields of the Tiff.TagID structure are valid tag names that contain the corresponding tag numeric identifiers. For instance, the field Tiff.TagID.ImageWidth contains the value 256. To see a list of all the tags along with their numeric identifiers, type Tiff.TagID in the command window.

Example: 'ImageWidth'

Example: 256

Example: Tiff.TagID.ImageWidth

Data Types: double | char | string

Algorithms

collapse all

References

This function corresponds to the TIFFGetField function in the LibTIFF C API. To use this function, you must be familiar with the TIFF specification and technical notes. View this documentation at LibTIFF - TIFF Library and Utilities.

Version History

Introduced in R2009b