Reads all the tags stored in a TIFF file.
public Leadtools.RasterCollection<RasterTagMetadata> ReadTags(string fileName,int pageNumber)
Public Overloads Function ReadTags( _ByVal fileName As String, _ByVal pageNumber As Integer _) As Leadtools.RasterCollection(Of RasterTagMetadata)
public Leadtools.RasterCollection<RasterTagMetadata> ReadTags(string fileName,int pageNumber)
- (nullable NSArray<LTRasterTagMetadata *> *)readTagsFromFile:(NSString *)filepageNumber:(NSInteger)pageNumbererror:(NSError **)error
function Leadtools.Codecs.RasterCodecs.ReadTags(String,Int32)(fileName ,pageNumber)
public:Leadtools.RasterCollection<RasterTagMetadata^>^ ReadTags(String^ fileName,int pageNumber)
fileName
A String containing the input file name.
pageNumber
1-based index of the page from which to read the tags.
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 metadata (tags, geo-keys and comments) found in a disk file.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;public void MetadataLoadExample(){// Prompt the user for an image filestring imageFileName = PromptForFileName();// Initialize LEADTOOLSusing (RasterCodecs codecs = new RasterCodecs()){// Get the file formatRasterImageFormat format;using (CodecsImageInfo info = codecs.GetInformation(imageFileName, false)){format = info.Format;}// Load the tagsRasterCollection<RasterTagMetadata> tags = null;if (RasterCodecs.TagsSupported(format))tags = codecs.ReadTags(imageFileName, 1);// Load the commentsRasterCollection<RasterCommentMetadata> comments = null;if (RasterCodecs.CommentsSupported(format))comments = codecs.ReadComments(imageFileName, 1);// Load the geo keysRasterCollection<RasterTagMetadata> geoKeys = null;if (RasterCodecs.GeoKeysSupported(format))geoKeys = codecs.ReadGeoKeys(imageFileName, 1);// Load the markersRasterCollection<RasterMarkerMetadata> markers = null;if (RasterCodecs.MarkersSupported(format))markers = codecs.ReadMarkers(imageFileName);string txtFileName = Path.Combine(Path.GetDirectoryName(imageFileName),Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt");using (StreamWriter writer = File.CreateText(txtFileName)){// Write the tagsWriteTags(writer, "Tags", tags);// Write the commentsWriteComments(writer, comments);// Write the geo keys (tags and geokeys use the same data type)WriteTags(writer, "GeoKeys", geoKeys);// Write the markersWriteMarkers(writer, markers);}// Show the text file we createdSystem.Diagnostics.Process.Start(txtFileName);}}private static void WriteTags(StreamWriter writer, string name, RasterCollection<RasterTagMetadata> tags){writer.WriteLine("{0}:", name);if (tags != null){foreach (RasterTagMetadata tag in tags){writer.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length);}}else{writer.WriteLine("Not supported");}writer.WriteLine();}private static void WriteComments(StreamWriter writer, RasterCollection<RasterCommentMetadata> comments){writer.WriteLine("Comments:");if (comments != null){foreach (RasterCommentMetadata comment in comments){writer.WriteLine("Type: {0}, data length: {1}", comment.Type, comment.GetData().Length);}}else{writer.WriteLine("Not supported");}writer.WriteLine();}private static void WriteMarkers(StreamWriter writer, RasterCollection<RasterMarkerMetadata> markers){writer.WriteLine("Markers:");if (markers != null){foreach (RasterMarkerMetadata marker in markers){writer.WriteLine("ID: {0}, data length: {1}", marker.Id, marker.GetData().Length);}}else{writer.WriteLine("Not supported");}writer.WriteLine();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPublic Sub MetadataLoadExample()' Prompt the user for an image fileDim imageFileName As String = PromptForFileName()' Initialize LEADTOOLSUsing codecs As New RasterCodecs()' Get the file formatDim format As RasterImageFormatUsing info As CodecsImageInfo = codecs.GetInformation(imageFileName, False)format = info.FormatEnd Using' Load the tagsDim tags As RasterCollection(Of RasterTagMetadata) = NothingIf RasterCodecs.TagsSupported(format) Thentags = codecs.ReadTags(imageFileName, 1)End If' Load the commentsDim comments As RasterCollection(Of RasterCommentMetadata) = NothingIf RasterCodecs.CommentsSupported(format) Thencomments = codecs.ReadComments(imageFileName, 1)End If' Load the geo keysDim geoKeys As RasterCollection(Of RasterTagMetadata) = NothingIf RasterCodecs.GeoKeysSupported(format) ThengeoKeys = codecs.ReadGeoKeys(imageFileName, 1)End If' Load the markersDim markers As RasterCollection(Of RasterMarkerMetadata) = NothingIf RasterCodecs.MarkersSupported(format) Thenmarkers = codecs.ReadMarkers(imageFileName)End IfDim txtFileName As String = Path.Combine(Path.GetDirectoryName(imageFileName),Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt")Using writer As StreamWriter = File.CreateText(txtFileName)' Write the tagsWriteTags(writer, "Tags", tags)' Write the commentsWriteComments(writer, comments)' Write the geo keys (tags and geokeys use the same data type)WriteTags(writer, "GeoKeys", geoKeys)' Write the markersWriteMarkers(writer, markers)End Using' Show the text file we createdSystem.Diagnostics.Process.Start(txtFileName)End UsingEnd SubPrivate Shared Sub WriteTags(ByVal writer As StreamWriter, ByVal name As String, ByVal tags As RasterCollection(Of RasterTagMetadata))writer.WriteLine("{0}:", name)If Not IsNothing(tags) ThenFor Each tag As RasterTagMetadata In tagswriter.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length)NextElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End SubPrivate Shared Sub WriteComments(ByVal writer As StreamWriter, ByVal comments As RasterCollection(Of RasterCommentMetadata))writer.WriteLine("Comments:")If Not IsNothing(comments) ThenFor Each comment As RasterCommentMetadata In commentswriter.WriteLine("Type: {0}, data length: {1}", comment.Type, comment.GetData().Length)NextElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End SubPrivate Shared Sub WriteMarkers(ByVal writer As StreamWriter, ByVal markers As RasterCollection(Of RasterMarkerMetadata))writer.WriteLine("Comments:")If Not IsNothing(markers) ThenFor Each marker As RasterMarkerMetadata In markerswriter.WriteLine("ID: {0}, data length: {1}", marker.Id, marker.GetData().Length)NextElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End Sub
using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Windows.Media;public void MetadataLoadExample(Stream inStreamImage, StreamWriter outStreamText){// Initialize LEADTOOLSRasterCodecs codecs = new RasterCodecs();{// Get the file formatRasterImageFormat format;CodecsImageInfo info = codecs.GetInformation(inStreamImage, false);{format = info.Format;}// Load the tagsRasterCollection<RasterTagMetadata> tags = null;if (RasterCodecs.TagsSupported(format))tags = codecs.ReadTags(inStreamImage, 1);// Load the commentsRasterCollection<RasterCommentMetadata> comments = null;if (RasterCodecs.CommentsSupported(format))comments = codecs.ReadComments(inStreamImage, 1);// Load the geo keysRasterCollection<RasterTagMetadata> geoKeys = null;if (RasterCodecs.GeoKeysSupported(format))geoKeys = codecs.ReadGeoKeys(inStreamImage, 1);// Write the tagsWriteTags(outStreamText, "Tags", tags);// Write the commentsWriteComments(outStreamText, comments);// Write the geo keys (tags and geokeys use the same data type)WriteTags(outStreamText, "GeoKeys", geoKeys);}}private static void WriteTags(StreamWriter writer, string name, RasterCollection<RasterTagMetadata> tags){writer.WriteLine("{0}:", name);if (tags != null){foreach (RasterTagMetadata tag in tags){writer.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length);}}else{writer.WriteLine("Not supported");}writer.WriteLine();}private static void WriteComments(StreamWriter writer, RasterCollection<RasterCommentMetadata> comments){writer.WriteLine("Comments:");if (comments != null){foreach (RasterCommentMetadata comment in comments){writer.WriteLine("Type: {0}, data length: {1}", comment.Type, comment.GetData().Length);}}else{writer.WriteLine("Not supported");}writer.WriteLine();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPublic Sub MetadataLoadExample(ByVal inStreamImage As Stream, ByVal outStreamText As StreamWriter)' Initialize LEADTOOLSDim codecs As RasterCodecs = New RasterCodecs()' Get the file formatDim format As RasterImageFormatDim info As CodecsImageInfo = codecs.GetInformation(inStreamImage, False)format = info.Format' Load the tagsDim tags As RasterCollection(Of RasterTagMetadata) = NothingIf RasterCodecs.TagsSupported(format) Thentags = codecs.ReadTags(inStreamImage, 1)End If' Load the commentsDim comments As RasterCollection(Of RasterCommentMetadata) = NothingIf RasterCodecs.CommentsSupported(format) Thencomments = codecs.ReadComments(inStreamImage, 1)End If' Load the geo keysDim geoKeys As RasterCollection(Of RasterTagMetadata) = NothingIf RasterCodecs.GeoKeysSupported(format) ThengeoKeys = codecs.ReadGeoKeys(inStreamImage, 1)End If' Write the tagsWriteTags(outStreamText, "Tags", tags)' Write the commentsWriteComments(outStreamText, comments)' Write the geo keys (tags and geokeys use the same data type)WriteTags(outStreamText, "GeoKeys", geoKeys)End SubPrivate Shared Sub WriteTags(ByVal writer As StreamWriter, ByVal name As String, ByVal tags As RasterCollection(Of RasterTagMetadata))writer.WriteLine("{0}:", name)If Not tags Is Nothing ThenFor Each tag As RasterTagMetadata In tagswriter.WriteLine("Id: 0x{0}, data length: {1}", tag.Id.ToString("X"), tag.GetData().Length)Next tagElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End SubPrivate Shared Sub WriteComments(ByVal writer As StreamWriter, ByVal comments As RasterCollection(Of RasterCommentMetadata))writer.WriteLine("Comments:")If Not comments Is Nothing ThenFor Each comment As RasterCommentMetadata In commentswriter.WriteLine("Type: {0}, data length: {1}", comment.Type, comment.GetData().Length)Next commentElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End Sub
ReadTag(String,Int32,Int32) Method
Implementing TIFF Comments and Tags
|
Products |
Support |
Feedback: ReadTags(String,Int32) Method - Leadtools.Codecs |
Introduction |
Help Version 19.0.2017.6.16
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.