Read value of tags from TIFF files.
file must be a TIFF file and tag should be a tag ID. To check multiple tags, tag can be a vector. If ifd is supplied, only those IFDs (Image File Directory) will be read. As with tag, multiple IFDs can be checked by using a vector or with the string ‘all’. By default, only the first IFD is read.
value and offset will be a matrix with a number of rows and columns equal to the number of tags and ifds requested. The index relate to the same order as the input. offset has the same structure as value and when equal to 1 its matching value on value will be an offset to a position in the file.
tags that can’t be found will have a value of 0 and the corresponding offset will be 2.
If an error occurs when reading file (such as lack of permissions of file is not a TIFF file), offset is set to -1 and value contains the error message.
See the following examples:
## read value of tag 258 on IFD 1 (`off' will be 1 if `val' is an offset or 2 if not found) [val, off] = tiff_tag_read (filepath, 258);
## read value 258, 262, 254 o IFD 1 (`val' and `off' will be a 1x3 matrix) [val, off] = tiff_tag_read (filepath, [258 262 254]); if (off(1) == -1), error ("something happened: %s", val); endif off(2,1) # will be 1 if val(2,1) is an offset to a file position or 2 if tag was not found val(2,1) # value of tag 262 on IFD 1
## read value 258, 262, 254 on the first 10 IFDs 1 (`val' and `off' will be a 1x10 matrix) [val, off] = tiff_tag_read (filepath, [258 262 254], 1:10); val(2,5) # value of tag 262 on IFD 5
## read value 258, 262, 254 o IFD 1 (`val' and `off' will be a 1x3 matrix) [val, off] = tiff_tag_read (filepath, [258 262 254], "all"); val(2,end) # value of tag 262 on the last IFD
See also: imread, imfinfo.
Package: image