←Select platform

ReadTagsWithOffsets(string,int,out long[]) Method

Reads all the tags stored in a TIFF file, along with the offsets for each tag.
public IList<RasterTagMetadata> ReadTagsWithOffsets( 
   string fileName, 
   int pageNumber, 
   out long[] offsets 
vb[VB Syntax] 
Public Overloads Function ReadTagsWithOffsets( _ 
   ByVal _fileName_ As String, _ 
   ByVal _pageNumber_ As Integer, _ 
   ByRef _offsets_ As Long() _ 
) As IList(Of RasterTagMetadata) 
- (nullable NSArray<LTRasterTagMetadata *> *)readTagsFromFile:(NSString *)file  
                                                      offsets:(NSMutableArray<NSNumber *> *)offsets  
                                                        error:(NSError **)error 
IList<RasterTagMetadata^>^ ReadTagsWithOffsets(  
   String^ fileName, 
   int pageNumber, 
   [Out] array<int64> offsets 


A String containing the input file name.

1-based index of the page from which to read the tags.

An array that contains the offsets for each tag.

Return Value

A collection of RasterTagMetadata containing all the tags found in the file. If the file does not contain any tags, an empty collection will be returned. If the file format does not support tags, an exception will be thrown.


To read a specific tag stored in a file, use ReadTag and to enumerate all the tag ids (but not the data) stored in a file use EnumTags.

This method will throw an exception if the file format does not support tags. To determine whether a file format supports tags, use TagsSupported. You can also automatically load all the tags stored in a file during a load operation by setting the CodecsLoadOptions.Tags property to true. The tags data will be stored in the resulting image RasterImage.Tags collection.

To load all the tags stored in a stream containing the image data, use ReadTags.


This example will load all the tags, with their offsets, from a file.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
public void ReadTagsWithOffsetsExample() 
	// Prompt the user for an image file 
	string imageFileName = PromptForFileName(); 
	// Initialize LEADTOOLS 
	using (RasterCodecs codecs = new RasterCodecs()) 
		// Get the file format 
		RasterImageFormat format; 
		using (CodecsImageInfo info = codecs.GetInformation(imageFileName, false)) 
			format = info.Format; 
		// Load the tags, with their offsets 
		IList<RasterTagMetadata> tags = null; 
		long[] offsets = null; 
		if (RasterCodecs.TagsSupported(format)) 
			tags = codecs.ReadTagsWithOffsets(imageFileName, 1, out offsets); 
		string txtFileName = Path.Combine( 
		   Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt"); 
		using (StreamWriter writer = File.CreateText(txtFileName)) 
			// Write the tags 
			WriteTags(writer, "Tags", tags, offsets); 
		// Show the text file we created 
private static void WriteTags(StreamWriter writer, string name, IList<RasterTagMetadata> tags, long[] offsets) 
	writer.WriteLine("{0}:", name); 
	if (tags != null) 
		int x = 0; 
		foreach (RasterTagMetadata tag in tags) 
			writer.WriteLine("Id: 0x{0}, offset: {1}", tag.Id.ToString("X"), offsets[x]); 
		writer.WriteLine("Not supported"); 

Target Platforms

Help Version 22.0.2022.4.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.