Tiff.getTag

Reads the value of a TIFF tag of the current directory.

Category: Data Import and Analysis > Data Import and Export

Syntax

value = getTag(t, tagName)

Returns the value of the named tag.

Description

The method acts on a Tiff object created with Tiff(filename, mode). Asking for a tag that the file does not contain is an error. The list of tag names that the class knows comes from Tiff.getTagNames.

Input arguments

t
Tiff object opened for reading.
tagName
Tag name such as 'ImageWidth', 'BitsPerSample', 'Compression' or 'Photometric'.

Output arguments

value
Tag value. Coded tags return numbers that you compare with constants such as Tiff.Photometric.MinIsBlack.

Example

Image properties

tag.ImageLength = 8; tag.ImageWidth = 8;
tag.Photometric = Tiff.Photometric.MinIsBlack;
tag.BitsPerSample = 8; tag.SamplesPerPixel = 1; tag.RowsPerStrip = 4;
tag.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
I = uint8(magic(8) * 3);
w = Tiff('t.tif', 'w'); w.setTag(tag); w.write(I); w.close();
r = Tiff('t.tif', 'r');
r.getTag('ImageWidth')
r.getTag('ImageLength')
r.getTag('BitsPerSample')
r.getTag('RowsPerStrip')
r.getTag('Photometric') == Tiff.Photometric.MinIsBlack
r.close();
Output
ans = 8
ans = 8
ans = 8
ans = 4
ans = logical
   1

See also

Tiff.setTag Tiff.getTagNames imfinfo Tiff.read