Implementing TIFF Comments and Tags

Show in webframe

The TIFF file formats support a number of comments that are saved and loaded using predefined tags. To specify the comments or tags set them directly in the image. The RasterImage has a Tags and Comments collection for adding, removing, inserting, clearing, and getting and setting tags.

To read a comment from an existing file, use RasterCodecs.ReadComment method. To read a comment from a file at a specified location, use the version of RasterCodecs.ReadComment that takes a stream and offset. To read all comments from an existing file, use RasterCodecs.ReadComments.

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

To write comments to an existing file, use RasterCodecs.WriteComments For a list of possible comments, refer to TIFF File Comments

Some restrictions apply if you use an Image File Directory (IFD) offset to indicate to which page to write a comment or tag. See the Loading And Saving Large TIFF Files topic for more information.

If the comments do not meet your needs, define a custom 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, register your tag by contacting Adobe Developer Relations. (The E-Mail address posted on The Unofficial TIFF Home Page is qapdevsup@adobe.com .)

To load tagged data from a file, use the RasterCodecs.ReadTag method. To write tags to an existing file, or to change existing tags in a file, use RasterCodecs.WriteTag or RasterCodecs.WriteTags methods.

To specify whether to save metadata during file saves, call RasterCodecs.CodecsOptions.CodecsSaveOptions.Comments or RasterCodecs.CodecsOptions.CodecsSaveOptions.Tags.

Note: To write tags to a TIFF file, use RasterCodecs.WriteTags instead of using RasterImage.Tags followed by RasterCodecs.Save.

EnumTags enumerates all tags in a TIFF or Exif file. For each tag enumerated, the TagFound event is fired. Through this event, you can obtain information about, or otherwise process, each tag that is enumerated.

When modifying collections, you need to tell the RasterCodecs engine to save the tags when creating the file. Do so by calling CodecsSaveOptions.Comments or CodecsSaveOptions.Tags, whichever is appropriate. Saving the tags at the same time as the image is a far more efficient way to create files, rather than saving the image and then using the WriteTags method in a separate operation.

Delete a specified tag from a file using the DeleteTag method.

Both the Tags collection and the WriteTags method specify RasterCollections of RasterTagMetaData. Multiple tags can be written at the same time.

To write private tags in a TIFF or EXIF file, refer to Working With Private TIFF Tags.

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.