VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    TIFF: How to get information about tags of TIFF file?
    In This Topic
    Here is C#/VB.NET code that shows how to get information about tags of TIFF file:
    namespace UserGuide.Programming.Tiff
    {
        class GetInformationAboutTagsOfTIFF
        {
    
            public static void GetTagsInfoAboutTiff(string fileName)
            {
                // open TIFF file
                using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiff = 
                    new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(fileName))
                {
                    System.Console.WriteLine(string.Format("Pages count: {0}", tiff.Pages.Count));
    
                    // for each page of TIFF file
                    Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffPage page;
                    for (int i = 0; i < tiff.Pages.Count; i++)
                    {
                        page = tiff.Pages[i];
    
                        // show information about tags of TIFF page
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags = page.IFD.Tags;
                        System.Console.WriteLine(string.Format("  - TIFF Tags [{0}]", tags.Count));
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag tag;
                        for (int j = 0; j < tags.Count; j++)
                        {
                            tag = tags[j];
                            System.Console.WriteLine(string.Format("    - Name: {0}", tag.Name));
                            System.Console.WriteLine(string.Format("    - DataType: {0}", tag.Type));
                            System.Console.WriteLine(string.Format("    - Count: {0}", tag.Count));
                            System.Console.WriteLine(string.Format("    - Data: {0}", tag.Data));
                        }
    
                        // show information about EXIF tags of TIFF page
                        tags = page.IFD.ExifTags;
                        System.Console.WriteLine(string.Format("  - EXIF Tags [{0}]", tags.Count));
                        for (int j = 0; j < tags.Count; j++)
                        {
                            tag = tags[j];
                            System.Console.WriteLine(string.Format("    - Name: {0}", tag.Name));
                            System.Console.WriteLine(string.Format("    - DataType: {0}", tag.Type));
                            System.Console.WriteLine(string.Format("    - Count: {0}", tag.Count));
                            System.Console.WriteLine(string.Format("    - Data: {0}", tag.Data));
                        }
    
                        // show information about GPS tags of TIFF page
                        tags = page.IFD.GpsTags;
                        System.Console.WriteLine(string.Format("  - GPS Tags [{0}]", tags.Count));
                        for (int j = 0; j < tags.Count; j++)
                        {
                            tag = tags[j];
                            System.Console.WriteLine(string.Format("    - Name: {0}", tag.Name));
                            System.Console.WriteLine(string.Format("    - DataType: {0}", tag.Type));
                            System.Console.WriteLine(string.Format("    - Count: {0}", tag.Count));
                            System.Console.WriteLine(string.Format("    - Data: {0}", tag.Data));
                        }
    
                        // show information about Interoperability tags of TIFF page
                        tags = page.IFD.InteroperabilityTags;
                        System.Console.WriteLine(string.Format("  - Interoperability Tags [{0}]", tags.Count));
                        for (int j = 0; j < tags.Count; j++)
                        {
                            tag = tags[j];
                            System.Console.WriteLine(string.Format("    - Name: {0}", tag.Name));
                            System.Console.WriteLine(string.Format("    - DataType: {0}", tag.Type));
                            System.Console.WriteLine(string.Format("    - Count: {0}", tag.Count));
                            System.Console.WriteLine(string.Format("    - Data: {0}", tag.Data));
                        }
                    }
                }
            }
    
        }
    }
    
    Namespace UserGuide.Programming.Tiff
        Class GetInformationAboutTagsOfTIFF
    
            Public Shared Sub GetTagsInfoAboutTiff(fileName As String)
                ' open TIFF file
                Using tiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(fileName)
                    System.Console.WriteLine(String.Format("Pages count: {0}", tiff.Pages.Count))
    
                    ' for each page of TIFF file
                    Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffPage
                    For i As Integer = 0 To tiff.Pages.Count - 1
                        page = tiff.Pages(i)
    
                        ' show information about tags of TIFF page
                        Dim tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection = page.IFD.Tags
                        System.Console.WriteLine(String.Format("  - TIFF Tags [{0}]", tags.Count))
                        Dim tag As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag
                        For j As Integer = 0 To tags.Count - 1
                            tag = tags(j)
                            System.Console.WriteLine(String.Format("    - Name: {0}", tag.Name))
                            System.Console.WriteLine(String.Format("    - DataType: {0}", tag.Type))
                            System.Console.WriteLine(String.Format("    - Count: {0}", tag.Count))
                            System.Console.WriteLine(String.Format("    - Data: {0}", tag.Data))
                        Next
    
                        ' show information about EXIF tags of TIFF page
                        tags = page.IFD.ExifTags
                        System.Console.WriteLine(String.Format("  - EXIF Tags [{0}]", tags.Count))
                        For j As Integer = 0 To tags.Count - 1
                            tag = tags(j)
                            System.Console.WriteLine(String.Format("    - Name: {0}", tag.Name))
                            System.Console.WriteLine(String.Format("    - DataType: {0}", tag.Type))
                            System.Console.WriteLine(String.Format("    - Count: {0}", tag.Count))
                            System.Console.WriteLine(String.Format("    - Data: {0}", tag.Data))
                        Next
    
                        ' show information about GPS tags of TIFF page
                        tags = page.IFD.GpsTags
                        System.Console.WriteLine(String.Format("  - GPS Tags [{0}]", tags.Count))
                        For j As Integer = 0 To tags.Count - 1
                            tag = tags(j)
                            System.Console.WriteLine(String.Format("    - Name: {0}", tag.Name))
                            System.Console.WriteLine(String.Format("    - DataType: {0}", tag.Type))
                            System.Console.WriteLine(String.Format("    - Count: {0}", tag.Count))
                            System.Console.WriteLine(String.Format("    - Data: {0}", tag.Data))
                        Next
    
                        ' show information about Interoperability tags of TIFF page
                        tags = page.IFD.InteroperabilityTags
                        System.Console.WriteLine(String.Format("  - Interoperability Tags [{0}]", tags.Count))
                        For j As Integer = 0 To tags.Count - 1
                            tag = tags(j)
                            System.Console.WriteLine(String.Format("    - Name: {0}", tag.Name))
                            System.Console.WriteLine(String.Format("    - DataType: {0}", tag.Type))
                            System.Console.WriteLine(String.Format("    - Count: {0}", tag.Count))
                            System.Console.WriteLine(String.Format("    - Data: {0}", tag.Data))
                        Next
                    Next
                End Using
            End Sub
    
        End Class
    End Namespace