%% Get Tag Value
% 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')

% Alternatively, specify the tag by its numeric identifier.

tagval1 = getTag(t,256)

% 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)

%
% Close the Tiff object.

close(t);

% Copyright 2012 The MathWorks, Inc.