public RasterTagMetadata ReadTag(
string fileName,
int pageNumber,
int id
)
- (nullable LTRasterTagMetadata *)readTag:(NSUInteger)tagId
fromFile:(NSString *)file
pageNumber:(NSInteger)pageNumber
error:(NSError **)error
public:
RasterTagMetadata^ ReadTag(
String^ fileName,
int pageNumber,
int id
)
def ReadTag(self,fileName,pageNumber,id):
fileName
A String containing the input file name.
pageNumber
1-based index of the page from which to read the tag.
id
Tag to identify the data in the TIFF file (or file format that supports Exif metadata). Use the same tag that you specified in the WriteTag. Examples of registered tags are:
Value | Meaning |
---|---|
0x8298 | Copyright comment |
0x8769 | General Exif comments |
0x8825 | Exif GPS comments |
0x80A4 | Annotation TIFF tag |
The tag data.
This method is provided to support TIFF tags that you define. If no such tag exists in the image, this method will return a null reference.
To read all the tags stored in a file, use ReadTags
You can use TagsSupported to determine whether a certain file format supports tags.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
public void TagExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_CustomTag.tif");
// Convert the source file to TIF
Debug.WriteLine("Converting the source file to TIF");
codecs.Convert(srcFileName, destFileName, RasterImageFormat.Tif, 0, 0, 24, null);
const int customTagId = 0x8000; /* 32768 in decimal */
int customTagValue = 7;
RasterTagMetadata writeTag = new RasterTagMetadata();
writeTag.Id = customTagId;
writeTag.DataType = RasterTagMetadataDataType.Int32;
writeTag.FromInt32(new int[] { customTagValue });
Debug.WriteLine("Writing the following tag to the file:");
Debug.WriteLine(" ID: {0}", writeTag.Id);
Debug.WriteLine(" DataType: {0}", writeTag.DataType);
Console.Write(" Data: ");
byte[] writeTagData = writeTag.GetData();
for (int i = 0; i < writeTagData.Length; i++)
Console.Write("{0:X} ", writeTagData[i]);
Debug.WriteLine(" ");
// Add the tag
Debug.WriteLine("Writing the custom tag with data = {0} to the file", customTagValue);
codecs.WriteTag(destFileName, 1, writeTag);
// Read the tag and make sure its in the file
Debug.WriteLine("Reading the custom tag from the file");
RasterTagMetadata readTag = codecs.ReadTag(destFileName, 1, customTagId);
Debug.WriteLine("Tag read from the file:");
Debug.WriteLine(" ID: {0}", readTag.Id);
Debug.WriteLine(" DataType: {0}", readTag.DataType);
Console.Write(" Data: ");
byte[] readTagData = readTag.GetData();
for (int i = 0; i < readTagData.Length; i++)
Console.Write("{0:X} ", readTagData[i]);
Debug.WriteLine(" ");
Debug.Assert(writeTag.Id == readTag.Id);
Debug.Assert(writeTag.DataType == readTag.DataType);
Debug.Assert(writeTagData.Length == writeTagData.Length);
for (int i = 0; i < writeTagData.Length; i++)
Debug.Assert(writeTagData[i] == readTagData[i]);
// Delete the tag from the file
Debug.WriteLine("Deleting the tag from the file");
codecs.DeleteTag(destFileName, 1, customTagId);
// Make sure the tag is deleted
Debug.WriteLine("Reading the tag from the file again");
readTag = codecs.ReadTag(destFileName, 1, customTagId);
if (readTag == null)
Debug.WriteLine("Tag was not found");
else
Debug.WriteLine("Tag is found, this should not happen");
Debug.Assert(readTag == null);
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document