setTag(t,tagID,tagValue)
sets the value of the TIFF tag specified by tagID to the value
specified by tagValue in the TIFF file associated with the
tiff object t.
You can set tags for a TIFF file by specifying the tag name, the tag numeric identifier, or by specifying a structure of multiple tag names and values.
Create a new TIFF file, write image data, and then set tag values in different ways.
Read sample data into an array, imdata. Create a Tiff object associated with a new file, myfile.tif, and open the file for writing.
imdata = imread('example.tif');
t = Tiff('myfile.tif','w');
Set tag values by specifying the numeric tag identifier. Use the fields of the Tiff.TagID structure to obtain the tag IDs. For instance, the Tiff.TagID.ImageLength contains the numeric identifier for the ImageLength tag.
Create a structure with fields named after TIFF tags and assign values to the fields. Pass this structure to the setTag method to set the values of these tags.
Tiff object representing a TIFF file. Use the Tiff function to create the object.
tagID — Tag ID character vector | string scalar | numeric identifier
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
tagValue — Tag value numeric identifier
Tag value, specified as a valid numeric identifier.
For example, you can specify tagValue for the
PlanarConfiguration tag in one of these ways:
Numeric identifier 2 that sets the value of
the PlanarConfiguration tag indicating a
separate configuration
Field of the Tiff.PlanarConfiguration
structure
Tiff.PlanarConfiguration.Separate
The Tiff.PlanarConfiguration structure contains the
numeric identifiers for all the valid values for the
PlanarConfiguration tag. To see all the valid tag
values for any given tag, type Tiff.TagName in the
command window. For example, to see all the valid values for the
Photometric tag, type
Tiff.Photometric in the command window.
Data Types: double
tagStruct — Multiple tags structure
Multiple tags, specified as a structure containing tag names and their
corresponding values. The names of fields in tagstruct
must be the name of supported TIFF tags, and their corresponding values must
be valid TIFF tag values.
Data Types: struct
Tips
If you are modifying a tag rather than creating it, then you must use the
rewriteDirectory method after
using the setTag method.
This function corresponds to the TIFFSetField 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.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.