Implementing TIFF Comments and Tags

The TIFF file formats support a number of comments that are saved and loaded using predefined tags. To specify a comment to be saved, you can use the LFileSettings::SetComment and LFileSettings::GetComment functions. To read a comment from an existing file, you can use LFile::ReadComment or LMemoryFile::ReadComment. To read a comment from a file at a specified location, use the LFile::ReadCommentOffset function. To read all the comment fields stored in a file, use LFile::ReadComments. To free the data allocated by calling the LFile::ReadComments function, use LFile::FreeComments.


If an error occurred in reading all file comments using the LFile::ReadComments function, then no comments will be returned, and the user is responsible to find the valid metadata in the file.

For a list of possible comments, refer to TIFF File Comments.

If the comments do not meet your needs, you can define your own tag for saving additional non-raster data in a TIFF file. For example, you may want to define a tag to save annotations.

The TIFF 6.0 Specification sets aside a range of private tags that developers can define. To avoid conflicts with files created by other developers, you can register your tag by contacting Adobe Developer Relations. (The E-Mail address posted on The Unofficial TIFF Home Page is

To define a tag and to specify the data to save in the tag, you can use the LFileSettings::SetTag and LFileSettings::GetTag functions. To load the tagged data from a file, you can use LFile::ReadTag, LFile::ReadTags, or LMemoryFile::ReadTag. To read all the tags stored in a file, use LFile::ReadTags. To free the data allocated by calling the LFile::ReadTags function, use LFile::FreeTags. To write tags to an existing file, or to change existing tags in a file, use LFile::WriteTag.


To write tags to a TIFF file, use LFile::WriteTag instead of using LFileSettings::SetTag followed by LFile::Save or LMemoryFile::Save.

LFile::EnumTags enumerates all tags in a TIFF or Exif file. For each tag enumerated, the LFile::EnumTagsCallBack function is called. Through this callback function, you can obtain information about, or otherwise process, each tag that is enumerated. You can delete a specified tag from the file using LFile::DeleteTag.

The LEADTOOLS functions let you save one additional tag in a TIFF file. They are designed for future expansion to more than one tag.

NOTE: To save a region inside a TIFF file, you must have an unlocked Document, Vector, or Medical Imaging license

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C++ Class Library Help