VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
В этом разделе
    Введение в метаданные изображения
    В этом разделе
    Метаданные изображения хранят данные об изображении и определяют такие аспекты, как ключевые слова, GPS местоположение, информацию о камере и многое другое.


    SDK предоставляет возможность получать метаданные из файла изображения, редактировать существующие и добавлять новые метаданные. Все эти операции выполняются без загрузки изображения из файла.

    SDK позволяет работать со следующими типами метаданных:
    Существует 3 метода доступа к метаданным изображения:

    Доступ к метаданным объекта VintasoftImage

    Класс VintasoftImageMetadata обеспечивает упрощенный доступ к метаданным изображения в случае, если работа с изображением осуществляется с использованием класса VintasoftImage. Доступ к экземпляру класса VintasoftImageMetadata можно получить с помощью свойства VintasoftImage.Metadata.

    VintasoftImageMetadata класс предоставляет доступ к:
    Вот C#/VB.NET код, который демонстрирует, как получить информацию о пакетах аннотаций, которые хранятся в метаданных JPEG файла:
    public void PrintInfoAboutJpegFileAnnotations(string filename)
    {
        // create an instance of VintasoftImage class
        using (Vintasoft.Imaging.VintasoftImage jpegImage = new Vintasoft.Imaging.VintasoftImage(filename))
        {
            // get reference to a metadata tree of JPEG page
            Vintasoft.Imaging.Metadata.MetadataNode jpegPageMetadata = jpegImage.Metadata.MetadataTree;
    
            // create an instance of MetadataTreeHelper class
            Vintasoft.Imaging.Metadata.MetadataTreeHelper metadataTreeHelper = 
                new Vintasoft.Imaging.Metadata.MetadataTreeHelper(jpegPageMetadata);
    
            //
            if (!metadataTreeHelper.HasVintasoftBinaryAnnotations &&
                !metadataTreeHelper.HasVintasoftXmpAnnotations)
                System.Console.Write(string.Format("File '{0}' does not have annotations.", filename));
            else
            {
                if (metadataTreeHelper.HasVintasoftBinaryAnnotations)
                    System.Console.Write(string.Format("File '{0}' has VintasoftBinary annotations.", filename));
    
                if (metadataTreeHelper.HasVintasoftXmpAnnotations)
                    System.Console.Write(string.Format("File '{0}' has VintasoftXmp annotations.", filename));
            }
        }
    }
    
    Public Sub PrintInfoAboutJpegFileAnnotations(filename As String)
        ' create an instance of VintasoftImage class
        Using jpegImage As New Vintasoft.Imaging.VintasoftImage(filename)
            ' get reference to a metadata tree of JPEG page
            Dim jpegPageMetadata As Vintasoft.Imaging.Metadata.MetadataNode = jpegImage.Metadata.MetadataTree
    
            ' create an instance of MetadataTreeHelper class
            Dim metadataTreeHelper As New Vintasoft.Imaging.Metadata.MetadataTreeHelper(jpegPageMetadata)
    
            '
            If Not metadataTreeHelper.HasVintasoftBinaryAnnotations AndAlso Not metadataTreeHelper.HasVintasoftXmpAnnotations Then
                System.Console.Write(String.Format("File '{0}' does not have annotations.", filename))
            Else
                If metadataTreeHelper.HasVintasoftBinaryAnnotations Then
                    System.Console.Write(String.Format("File '{0}' has VintasoftBinary annotations.", filename))
                End If
    
                If metadataTreeHelper.HasVintasoftXmpAnnotations Then
                    System.Console.Write(String.Format("File '{0}' has VintasoftXmp annotations.", filename))
                End If
            End If
        End Using
    End Sub
    


    Дерево метаданных представляет метаданные изображения в виде древовидной структуры. Доступ к дереву метаданных можно получить с помощью свойства VintasoftImageMetadata.MetadataTree.
    Корневой узел дерева метаданных представляет страницу файла изображения. Каждый узел дерева может содержать информацию о метаданных изображения и дочерних узлах.


    Вот C#/VB.NET код, который демонстрирует, как получить информацию о тегах TIFF файла:
    public void PrintInfoAboutTiffFile(string filename)
    {
        // create an image collection
        Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection();
        // add TIFF file to a collection
        images.Add(filename);
    
        for (int i = 0; i < images.Count; i++)
        {
            System.Console.WriteLine(string.Format("Page {0}", i));
    
            // get reference to a metadata tree of TIFF page
            Vintasoft.Imaging.Metadata.MetadataNode tiffPageMetadata = images[i].Metadata.MetadataTree;
    
            // search for tree node that contains information about TIFF IFD
            Vintasoft.Imaging.Metadata.TiffIfdMetadata tiffIfdMetadata = 
                tiffPageMetadata.FindChildNode<Vintasoft.Imaging.Metadata.TiffIfdMetadata>();
            // if tree node that contains information about TIFF IFD is found
            if (tiffIfdMetadata != null)
            {
                // if TIFF IFD is found
                if (tiffIfdMetadata.ImageFileDirectory != null)
                    // print info about TIFF IFD data
                    PrintInfoAboutTiffIfdData(tiffIfdMetadata.ImageFileDirectory);
            }
        }
    }
    
    private void PrintInfoAboutTiffIfdData(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory ifd)
    {
        System.Console.WriteLine("  TIFF IFD data:");
    
        // print info about tag collection of EXIF data
        PrintTiffTagCollectionInfo(ifd.Tags, "    ");
    
        System.Console.WriteLine();
    }
    
    private void PrintTiffTagCollectionInfo(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags, string indent)
    {
        // print tag count
        System.Console.WriteLine(string.Format("{0}Tags [{1}]:", indent, tags.Count));
        // for each tag
        for (int i = 0; i < tags.Count; i++)
        {
            // print tag info
            System.Console.WriteLine(string.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags[i].Id, tags[i].Name, tags[i].Data));
    
            // if tag data is TiffImageFileDirectory
            if (tags[i].Data.GetType() == typeof(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory subIfd = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)tags[i].Data;
                // print info about tag collection of sub IFD
                PrintTiffTagCollectionInfo(subIfd.Tags, indent + "  ");
            }
            // if tag data is TiffImageFileDirectory[]
            if (tags[i].Data.GetType() == typeof(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[]))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[] subIfds = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[])tags[i].Data;
                for (int j = 0; j < subIfds.Length; j++)
                    // print info about tag collection of sub IFD
                    PrintTiffTagCollectionInfo(subIfds[j].Tags, indent + "  ");
            }
        }
    }
    
    Public Sub PrintInfoAboutTiffFile(filename As String)
        ' create an image collection
        Dim images As New Vintasoft.Imaging.ImageCollection()
        ' add TIFF file to a collection
        images.Add(filename)
    
        For i As Integer = 0 To images.Count - 1
            System.Console.WriteLine(String.Format("Page {0}", i))
    
            ' get reference to a metadata tree of TIFF page
            Dim tiffPageMetadata As Vintasoft.Imaging.Metadata.MetadataNode = images(i).Metadata.MetadataTree
    
            ' search for tree node that contains information about TIFF IFD
            Dim tiffIfdMetadata As Vintasoft.Imaging.Metadata.TiffIfdMetadata = tiffPageMetadata.FindChildNode(Of Vintasoft.Imaging.Metadata.TiffIfdMetadata)()
            ' if tree node that contains information about TIFF IFD is found
            If tiffIfdMetadata IsNot Nothing Then
                ' if TIFF IFD is found
                If tiffIfdMetadata.ImageFileDirectory IsNot Nothing Then
                    ' print info about TIFF IFD data
                    PrintInfoAboutTiffIfdData(tiffIfdMetadata.ImageFileDirectory)
                End If
            End If
        Next
    End Sub
    
    Private Sub PrintInfoAboutTiffIfdData(ifd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
        System.Console.WriteLine("  TIFF IFD data:")
    
        ' print info about tag collection of EXIF data
        PrintTiffTagCollectionInfo(ifd.Tags, "    ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintTiffTagCollectionInfo(tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection, indent As String)
        ' print tag count
        System.Console.WriteLine(String.Format("{0}Tags [{1}]:", indent, tags.Count))
        ' for each tag
        For i As Integer = 0 To tags.Count - 1
            ' print tag info
            System.Console.WriteLine(String.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags(i).Id, tags(i).Name, tags(i).Data))
    
            ' if tag data is TiffImageFileDirectory
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory) Then
                Dim subIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
                ' print info about tag collection of sub IFD
                PrintTiffTagCollectionInfo(subIfd.Tags, indent & "  ")
            End If
            ' if tag data is TiffImageFileDirectory[]
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory()) Then
                Dim subIfds As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory() = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory())
                For j As Integer = 0 To subIfds.Length - 1
                    ' print info about tag collection of sub IFD
                    PrintTiffTagCollectionInfo(subIfds(j).Tags, indent & "  ")
                Next
            End If
        Next
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как получить EXIF информация из JPEG файле:
    public void PrintExifInfoAboutJpegFile(string filename)
    {
        // create an instance of VintasoftImage class
        using (Vintasoft.Imaging.VintasoftImage jpegImage = new Vintasoft.Imaging.VintasoftImage(filename))
        {
            // get reference to a metadata tree of JPEG page
            Vintasoft.Imaging.Metadata.MetadataNode jpegPageMetadata = jpegImage.Metadata.MetadataTree;
            // search for tree node that contains information about JPEG thumbnail
            Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata jpegApp1ExifSegmentMetadata = 
                jpegPageMetadata.FindChildNode<Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata>();
            // if tree node that contains EXIF information is found
            if (jpegApp1ExifSegmentMetadata != null)
            {
                // if EXIF data is found
                if (jpegApp1ExifSegmentMetadata.IFD0 != null)
                    // print info about EXIF data
                    PrintInfoAboutExifData(jpegApp1ExifSegmentMetadata.IFD0);
    
                // if EXIF thumbnail data is found
                if (jpegApp1ExifSegmentMetadata.IFD1 != null)
                    // print info about EXIF thumbnail data
                    PrintInfoAboutExifThumbnailData(jpegApp1ExifSegmentMetadata.IFD1);
    
                // if EXIF thumbnail is found
                if (jpegApp1ExifSegmentMetadata.Thumbnail != null)
                    // print info about EXIF thumbnail
                    PrintInfoAboutExifThumbnail(jpegApp1ExifSegmentMetadata.Thumbnail);
            }
        }
    }
    
    private void PrintInfoAboutExifData(Vintasoft.Imaging.Metadata.JpegApp1Ifd0Metadata jpegApp1Ifd0Metadata)
    {
        System.Console.WriteLine("EXIF data:");
    
        // print info about tag collection of EXIF data
        PrintExifTagCollectionInfo(jpegApp1Ifd0Metadata.ImageFileDirectory.Tags, "  ");
    
        System.Console.WriteLine();
    }
    
    private void PrintInfoAboutExifThumbnailData(Vintasoft.Imaging.Metadata.JpegApp1Ifd1Metadata jpegApp1Ifd1Metadata)
    {
        System.Console.WriteLine("EXIF thumbnail data:");
    
        // print info about tag collection of EXIF thumbnail data
        PrintExifTagCollectionInfo(jpegApp1Ifd1Metadata.ImageFileDirectory.Tags, "  ");
    
        System.Console.WriteLine();
    }
    
    private void PrintInfoAboutExifThumbnail(Vintasoft.Imaging.Metadata.ThumbnailMetadata thumbnailMetadata)
    {
        System.Console.WriteLine("EXIF thumbnail:");
    
        // print info about EXIF thumbnail
        System.Console.WriteLine(string.Format("  Thumbnail size: {0}", thumbnailMetadata.ThumbnailSize));
    
        System.Console.WriteLine();
    }
    
    private void PrintExifTagCollectionInfo(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags, string indent)
    {
        // print tag count
        System.Console.WriteLine(string.Format("{0}Tags [{1}]:", indent, tags.Count));
        // for each tag
        for (int i = 0; i < tags.Count; i++)
        {
            // print tag info
            System.Console.WriteLine(string.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags[i].Id, tags[i].Name, tags[i].Data));
            
            // if tag data is TiffImageFileDirectory
            if (tags[i].Data.GetType() == typeof(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory subIfd = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)tags[i].Data;
                // print info about tag collection of sub IFD
                PrintExifTagCollectionInfo(subIfd.Tags, indent + "  ");
            }
            // if tag data is TiffImageFileDirectory[]
            if (tags[i].Data.GetType() == typeof(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[]))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[] subIfds = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[])tags[i].Data;
                for (int j = 0; j < subIfds.Length; j++)
                    // print info about tag collection of sub IFD
                    PrintExifTagCollectionInfo(subIfds[j].Tags, indent + "  ");
            }
        }
    }
    
    Public Sub PrintExifInfoAboutJpegFile(filename As String)
        ' create an instance of VintasoftImage class
        Using jpegImage As New Vintasoft.Imaging.VintasoftImage(filename)
            ' get reference to a metadata tree of JPEG page
            Dim jpegPageMetadata As Vintasoft.Imaging.Metadata.MetadataNode = jpegImage.Metadata.MetadataTree
            ' search for tree node that contains information about JPEG thumbnail
            Dim jpegApp1ExifSegmentMetadata As Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata = jpegPageMetadata.FindChildNode(Of Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata)()
            ' if tree node that contains EXIF information is found
            If jpegApp1ExifSegmentMetadata IsNot Nothing Then
                ' if EXIF data is found
                If jpegApp1ExifSegmentMetadata.IFD0 IsNot Nothing Then
                    ' print info about EXIF data
                    PrintInfoAboutExifData(jpegApp1ExifSegmentMetadata.IFD0)
                End If
    
                ' if EXIF thumbnail data is found
                If jpegApp1ExifSegmentMetadata.IFD1 IsNot Nothing Then
                    ' print info about EXIF thumbnail data
                    PrintInfoAboutExifThumbnailData(jpegApp1ExifSegmentMetadata.IFD1)
                End If
    
                ' if EXIF thumbnail is found
                If jpegApp1ExifSegmentMetadata.Thumbnail IsNot Nothing Then
                    ' print info about EXIF thumbnail
                    PrintInfoAboutExifThumbnail(jpegApp1ExifSegmentMetadata.Thumbnail)
                End If
            End If
        End Using
    End Sub
    
    Private Sub PrintInfoAboutExifData(jpegApp1Ifd0Metadata As Vintasoft.Imaging.Metadata.JpegApp1Ifd0Metadata)
        System.Console.WriteLine("EXIF data:")
    
        ' print info about tag collection of EXIF data
        PrintExifTagCollectionInfo(jpegApp1Ifd0Metadata.ImageFileDirectory.Tags, "  ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintInfoAboutExifThumbnailData(jpegApp1Ifd1Metadata As Vintasoft.Imaging.Metadata.JpegApp1Ifd1Metadata)
        System.Console.WriteLine("EXIF thumbnail data:")
    
        ' print info about tag collection of EXIF thumbnail data
        PrintExifTagCollectionInfo(jpegApp1Ifd1Metadata.ImageFileDirectory.Tags, "  ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintInfoAboutExifThumbnail(thumbnailMetadata As Vintasoft.Imaging.Metadata.ThumbnailMetadata)
        System.Console.WriteLine("EXIF thumbnail:")
    
        ' print info about EXIF thumbnail
        System.Console.WriteLine(String.Format("  Thumbnail size: {0}", thumbnailMetadata.ThumbnailSize))
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintExifTagCollectionInfo(tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection, indent As String)
        ' print tag count
        System.Console.WriteLine(String.Format("{0}Tags [{1}]:", indent, tags.Count))
        ' for each tag
        For i As Integer = 0 To tags.Count - 1
            ' print tag info
            System.Console.WriteLine(String.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags(i).Id, tags(i).Name, tags(i).Data))
    
            ' if tag data is TiffImageFileDirectory
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory) Then
                Dim subIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
                ' print info about tag collection of sub IFD
                PrintExifTagCollectionInfo(subIfd.Tags, indent & "  ")
            End If
            ' if tag data is TiffImageFileDirectory[]
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory()) Then
                Dim subIfds As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory() = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory())
                For j As Integer = 0 To subIfds.Length - 1
                    ' print info about tag collection of sub IFD
                    PrintExifTagCollectionInfo(subIfds(j).Tags, indent & "  ")
                Next
            End If
        Next
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как изменить GPS информацию в JPEG файле:
    public void ChangeGpsInfoAboutJpegFile(string filename)
    {
        // open a file stream in read-write mode
        using (System.IO.FileStream fs = new System.IO.FileStream(
            filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
        {
            // create an instance of VintasoftImage class
            using (Vintasoft.Imaging.VintasoftImage jpegImage = new Vintasoft.Imaging.VintasoftImage(fs))
            {
                // get reference to a metadata tree of JPEG page
                Vintasoft.Imaging.Metadata.MetadataNode jpegPageMetadata = jpegImage.Metadata.MetadataTree;
                // search for tree node that contains information about JPEG thumbnail
                Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata jpegApp1ExifSegmentMetadata = 
                    jpegPageMetadata.FindChildNode<Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata>();
                // if tree node that contains information about JPEG thumbnail is found
                if (jpegApp1ExifSegmentMetadata != null)
                {
                    // if EXIF data is found
                    if (jpegApp1ExifSegmentMetadata.IFD0 != null)
                    {
                        // if GPS info is not found
                        if (jpegApp1ExifSegmentMetadata.IFD0.GpsIFD == null)
                            // create node that contains GPS info
                            jpegApp1ExifSegmentMetadata.IFD0.CreateGpsIFD();
    
                        // get reference to a GPS IFD
                        Vintasoft.Imaging.Metadata.TiffIfdMetadata gpsIfd = jpegApp1ExifSegmentMetadata.IFD0.GpsIFD;
    
                        // search for tag that contains info about GPS date stamp
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag gpsDateStampTag = 
                            gpsIfd.ImageFileDirectory.Tags.Find((ushort)Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp);
                        // if tag that contains info about GPS date stamp is found
                        if (gpsDateStampTag != null)
                            // change the tag data
                            gpsDateStampTag.Data = System.DateTime.Now.ToString();
                        // if tag that contains info about GPS date stamp is not found
                        else
                            // add the GPS date stamp
                            gpsIfd.ImageFileDirectory.Tags.Add(
                                (ushort)Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp, 
                                System.DateTime.Now.ToString());
    
                        // create an encoder for image saving
                        Vintasoft.Imaging.Codecs.Encoders.JpegEncoder encoder = new Vintasoft.Imaging.Codecs.Encoders.JpegEncoder();
                        encoder.SaveAndSwitchSource = true;
                        // save changes to the source stream
                        jpegImage.Save(fs, encoder);
                    }
                }
            }
        }
    }
    
    Public Sub ChangeGpsInfoAboutJpegFile(filename As String)
        ' open a file stream in read-write mode
        Using fs As New System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite)
            ' create an instance of VintasoftImage class
            Using jpegImage As New Vintasoft.Imaging.VintasoftImage(fs)
                ' get reference to a metadata tree of JPEG page
                Dim jpegPageMetadata As Vintasoft.Imaging.Metadata.MetadataNode = jpegImage.Metadata.MetadataTree
                ' search for tree node that contains information about JPEG thumbnail
                Dim jpegApp1ExifSegmentMetadata As Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata = jpegPageMetadata.FindChildNode(Of Vintasoft.Imaging.Metadata.JpegApp1ExifSegmentMetadata)()
                ' if tree node that contains information about JPEG thumbnail is found
                If jpegApp1ExifSegmentMetadata IsNot Nothing Then
                    ' if EXIF data is found
                    If jpegApp1ExifSegmentMetadata.IFD0 IsNot Nothing Then
                        ' if GPS info is not found
                        If jpegApp1ExifSegmentMetadata.IFD0.GpsIFD Is Nothing Then
                            ' create node that contains GPS info
                            jpegApp1ExifSegmentMetadata.IFD0.CreateGpsIFD()
                        End If
    
                        ' get reference to a GPS IFD
                        Dim gpsIfd As Vintasoft.Imaging.Metadata.TiffIfdMetadata = jpegApp1ExifSegmentMetadata.IFD0.GpsIFD
    
                        ' search for tag that contains info about GPS date stamp
                        Dim gpsDateStampTag As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag = gpsIfd.ImageFileDirectory.Tags.Find(CUShort(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp))
                        ' if tag that contains info about GPS date stamp is found
                        If gpsDateStampTag IsNot Nothing Then
                            ' change the tag data
                            gpsDateStampTag.Data = System.DateTime.Now.ToString()
                        Else
                            ' if tag that contains info about GPS date stamp is not found
                            ' add the GPS date stamp
                            gpsIfd.ImageFileDirectory.Tags.Add(CUShort(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp), System.DateTime.Now.ToString())
                        End If
    
                        ' create an encoder for image saving
                        Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.JpegEncoder()
                        encoder.SaveAndSwitchSource = True
                        ' save changes to the source stream
                        jpegImage.Save(fs, encoder)
                    End If
                End If
            End Using
        End Using
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как получить миниатюру из JPEG файла:
    public Vintasoft.Imaging.VintasoftImage GetJpegThumbnail(string filename)
    {
        // create an instance of VintasoftImage class
        using (Vintasoft.Imaging.VintasoftImage jpegImage = 
            new Vintasoft.Imaging.VintasoftImage(filename))
        {
            // get reference to a metadata tree of JPEG page
            Vintasoft.Imaging.Metadata.MetadataNode jpegPageMetadata = jpegImage.Metadata.MetadataTree;
            // search for tree node that contains information about JPEG thumbnail
            Vintasoft.Imaging.Metadata.JpegApp1ThumbnailMetadata jpegThumbnailMetadata = 
                jpegPageMetadata.FindChildNode<Vintasoft.Imaging.Metadata.JpegApp1ThumbnailMetadata>();
            // if tree node that contains information about JPEG thumbnail is found
            if (jpegThumbnailMetadata != null)
                // return thumbnail of JPEG page
                return jpegThumbnailMetadata.ThumbnailImage;
    
            // JPEG page does not have thumbnail
            return null;
        }
    }
    
    Public Function GetJpegThumbnail(filename As String) As Vintasoft.Imaging.VintasoftImage
        ' create an instance of VintasoftImage class
        Using jpegImage As New Vintasoft.Imaging.VintasoftImage(filename)
            ' get reference to a metadata tree of JPEG page
            Dim jpegPageMetadata As Vintasoft.Imaging.Metadata.MetadataNode = jpegImage.Metadata.MetadataTree
            ' search for tree node that contains information about JPEG thumbnail
            Dim jpegThumbnailMetadata As Vintasoft.Imaging.Metadata.JpegApp1ThumbnailMetadata = jpegPageMetadata.FindChildNode(Of Vintasoft.Imaging.Metadata.JpegApp1ThumbnailMetadata)()
            ' if tree node that contains information about JPEG thumbnail is found
            If jpegThumbnailMetadata IsNot Nothing Then
                ' return thumbnail of JPEG page
                Return jpegThumbnailMetadata.ThumbnailImage
            End If
    
            ' JPEG page does not have thumbnail
            Return Nothing
        End Using
    End Function
    


    Доступ к метаданным экземпляра класса, который является производным от класса ImageFile

    ImageFileBase<T> класс - абстрактный класс, обеспечивающий доступ к файлу изображения. Для каждого поддерживаемого формата файла изображения существует класс, производный от ImageFileBase<T> class, а именно:
    Метаданные файла изображения можно получить, используя свойства и методы экземпляра класса, которые является производным от класса ImageFileBase<T> . Также экземпляр класса, производного от класса ImageFileBase<T> , обеспечивает доступ к страницам файла.

    Вот C#/VB.NET код, который демонстрирует, как получить формат и версию TIFF файла:
    public void PrintInfoAboutTiffFileFormatAndVersion(string filename)
    {
        // create an instance of TiffFile class
        using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiffFile = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(filename))
        {
            System.Console.WriteLine(string.Format("TIFF Format={0} Version={1}", tiffFile.Format, tiffFile.Version));
        }
    }
    
    Public Sub PrintInfoAboutTiffFileFormatAndVersion(filename As String)
        ' create an instance of TiffFile class
        Using tiffFile As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(filename)
            System.Console.WriteLine(String.Format("TIFF Format={0} Version={1}", tiffFile.Format, tiffFile.Version))
        End Using
    End Sub
    


    Класс ImagePage - это абстрактный класс, обеспечивающий доступ к странице изображения. Для каждого поддерживаемого формата файла изображения существует класс, производный от класса ImagePage, а именно:
    Метаданные страницы изображения можно получить, используя свойства и методы экземпляра класса, производного от класса ImagePage.


    Вот C#/VB.NET код, который демонстрирует, как получить информацию о тегах TIFF файла:
    public void PrintInfoAboutTiffFile(string filename)
    {
        // create an instance of TiffFile class
        using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiffFile = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(filename))
        {
            // for each TIFF page
            for (int i = 0; i < tiffFile.Pages.Count; i++)
            {
                System.Console.WriteLine(string.Format("Page {0}", i));
    
                // print info about TIFF IFD data
                PrintInfoAboutTiffIfdData(tiffFile.Pages[0].IFD);
            }
        }
    }
    
    private void PrintInfoAboutTiffIfdData(
        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory ifd)
    {
        System.Console.WriteLine("  TIFF IFD data:");
    
        // print info about tag collection of EXIF data
        PrintTiffTagCollectionInfo(ifd.Tags, "    ");
    
        System.Console.WriteLine();
    }
    
    private void PrintTiffTagCollectionInfo(
        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags, string indent)
    {
        // print tag count
        System.Console.WriteLine(string.Format("{0}Tags [{1}]:", indent, tags.Count));
        // for each tag
        for (int i = 0; i < tags.Count; i++)
        {
            // print tag info
            System.Console.WriteLine(string.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags[i].Id, tags[i].Name, tags[i].Data));
    
            // if tag data is TiffImageFileDirectory
            if (tags[i].Data.GetType() == typeof(
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory subIfd = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)tags[i].Data;
                // print info about tag collection of sub IFD
                PrintTiffTagCollectionInfo(subIfd.Tags, indent + "  ");
            }
            // if tag data is TiffImageFileDirectory[]
            if (tags[i].Data.GetType() == typeof(
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[]))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[] subIfds = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[])tags[i].Data;
                for (int j = 0; j < subIfds.Length; j++)
                    // print info about tag collection of sub IFD
                    PrintTiffTagCollectionInfo(subIfds[j].Tags, indent + "  ");
            }
        }
    }
    
    Public Sub PrintInfoAboutTiffFile(filename As String)
        ' create an instance of TiffFile class
        Using tiffFile As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(filename)
            ' for each TIFF page
            For i As Integer = 0 To tiffFile.Pages.Count - 1
                System.Console.WriteLine(String.Format("Page {0}", i))
    
                ' print info about TIFF IFD data
                PrintInfoAboutTiffIfdData(tiffFile.Pages(0).IFD)
            Next
        End Using
    End Sub
    
    Private Sub PrintInfoAboutTiffIfdData(ifd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
        System.Console.WriteLine("  TIFF IFD data:")
    
        ' print info about tag collection of EXIF data
        PrintTiffTagCollectionInfo(ifd.Tags, "    ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintTiffTagCollectionInfo(tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection, indent As String)
        ' print tag count
        System.Console.WriteLine(String.Format("{0}Tags [{1}]:", indent, tags.Count))
        ' for each tag
        For i As Integer = 0 To tags.Count - 1
            ' print tag info
            System.Console.WriteLine(String.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags(i).Id, tags(i).Name, tags(i).Data))
    
            ' if tag data is TiffImageFileDirectory
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory) Then
                Dim subIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
                ' print info about tag collection of sub IFD
                PrintTiffTagCollectionInfo(subIfd.Tags, indent & "  ")
            End If
            ' if tag data is TiffImageFileDirectory[]
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory()) Then
                Dim subIfds As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory() = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory())
                For j As Integer = 0 To subIfds.Length - 1
                    ' print info about tag collection of sub IFD
                    PrintTiffTagCollectionInfo(subIfds(j).Tags, indent & "  ")
                Next
            End If
        Next
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как получить EXIF информация из JPEG файле:
    public void PrintExifInfoAboutJpegFile(string filename)
    {
        // create an instance of JpegFile class
        using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile jpegFile = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename))
        {
            // if JPEG page contains EXIF information
            if (jpegFile.Page.Exif != null)
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData exifData = jpegFile.Page.Exif;
    
                // if EXIF data is found
                if (exifData.ImageFileDirectory != null)
                    // print info about EXIF data
                    PrintInfoAboutExifData(exifData.ImageFileDirectory);
    
                // if EXIF thumbnail data is found
                if (exifData.ThumbnailFileDirectory != null)
                    // print info about EXIF thumbnail data
                    PrintInfoAboutExifThumbnailData(exifData.ThumbnailFileDirectory);
    
                // if EXIF thumbnail is found
                if (exifData.HasThumbnail)
                    // print info about EXIF thumbnail
                    PrintInfoAboutExifThumbnail(exifData);
            }
        }
    }
    
    private void PrintInfoAboutExifData(
        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory exifDataIfd)
    {
        System.Console.WriteLine("EXIF data:");
    
        // print info about tag collection of EXIF data
        PrintExifTagCollectionInfo(exifDataIfd.Tags, "  ");
    
        System.Console.WriteLine();
    }
    
    private void PrintInfoAboutExifThumbnailData(
        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory exifThumbnailDataIfd)
    {
        System.Console.WriteLine("EXIF thumbnail data:");
    
        // print info about tag collection of EXIF thumbnail data
        PrintExifTagCollectionInfo(exifThumbnailDataIfd.Tags, "  ");
    
        System.Console.WriteLine();
    }
    
    private void PrintInfoAboutExifThumbnail(
        Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData exifData)
    {
        System.Console.WriteLine("EXIF thumbnail:");
    
        using (Vintasoft.Imaging.VintasoftImage thumbnailImage = exifData.GetThumbnail())
        {
            // print info about EXIF thumbnail
            System.Console.WriteLine(string.Format("  Thumbnail size: {0}x{1}", thumbnailImage.Width, thumbnailImage.Height));
        }
    
        System.Console.WriteLine();
    }
    
    private void PrintExifTagCollectionInfo(
        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags, string indent)
    {
        // print tag count
        System.Console.WriteLine(string.Format("{0}Tags [{1}]:", indent, tags.Count));
        // for each tag
        for (int i = 0; i < tags.Count; i++)
        {
            // print tag info
            System.Console.WriteLine(string.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags[i].Id, tags[i].Name, tags[i].Data));
            
            // if tag data is TiffImageFileDirectory
            if (tags[i].Data.GetType() == typeof(
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory subIfd = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)tags[i].Data;
                // print info about tag collection of sub IFD
                PrintExifTagCollectionInfo(subIfd.Tags, indent + "  ");
            }
            // if tag data is TiffImageFileDirectory[]
            if (tags[i].Data.GetType() == typeof(
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[]))
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[] subIfds = 
                    (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory[])tags[i].Data;
                for (int j = 0; j < subIfds.Length; j++)
                    // print info about tag collection of sub IFD
                    PrintExifTagCollectionInfo(subIfds[j].Tags, indent + "  ");
            }
        }
    }
    
    Public Sub PrintExifInfoAboutJpegFile(filename As String)
        ' create an instance of JpegFile class
        Using jpegFile As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename)
            ' if JPEG page contains EXIF information
            If jpegFile.Page.Exif IsNot Nothing Then
                Dim exifData As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData = jpegFile.Page.Exif
    
                ' if EXIF data is found
                If exifData.ImageFileDirectory IsNot Nothing Then
                    ' print info about EXIF data
                    PrintInfoAboutExifData(exifData.ImageFileDirectory)
                End If
    
                ' if EXIF thumbnail data is found
                If exifData.ThumbnailFileDirectory IsNot Nothing Then
                    ' print info about EXIF thumbnail data
                    PrintInfoAboutExifThumbnailData(exifData.ThumbnailFileDirectory)
                End If
    
                ' if EXIF thumbnail is found
                If exifData.HasThumbnail Then
                    ' print info about EXIF thumbnail
                    PrintInfoAboutExifThumbnail(exifData)
                End If
            End If
        End Using
    End Sub
    
    Private Sub PrintInfoAboutExifData(exifDataIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
        System.Console.WriteLine("EXIF data:")
    
        ' print info about tag collection of EXIF data
        PrintExifTagCollectionInfo(exifDataIfd.Tags, "  ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintInfoAboutExifThumbnailData(exifThumbnailDataIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
        System.Console.WriteLine("EXIF thumbnail data:")
    
        ' print info about tag collection of EXIF thumbnail data
        PrintExifTagCollectionInfo(exifThumbnailDataIfd.Tags, "  ")
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintInfoAboutExifThumbnail(exifData As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData)
        System.Console.WriteLine("EXIF thumbnail:")
    
        Using thumbnailImage As Vintasoft.Imaging.VintasoftImage = exifData.GetThumbnail()
            ' print info about EXIF thumbnail
            System.Console.WriteLine(String.Format("  Thumbnail size: {0}x{1}", thumbnailImage.Width, thumbnailImage.Height))
        End Using
    
        System.Console.WriteLine()
    End Sub
    
    Private Sub PrintExifTagCollectionInfo(tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection, indent As String)
        ' print tag count
        System.Console.WriteLine(String.Format("{0}Tags [{1}]:", indent, tags.Count))
        ' for each tag
        For i As Integer = 0 To tags.Count - 1
            ' print tag info
            System.Console.WriteLine(String.Format("{0}- Id={1}, Name={2}, Data={3}", indent, tags(i).Id, tags(i).Name, tags(i).Data))
    
            ' if tag data is TiffImageFileDirectory
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory) Then
                Dim subIfd As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory)
                ' print info about tag collection of sub IFD
                PrintExifTagCollectionInfo(subIfd.Tags, indent & "  ")
            End If
            ' if tag data is TiffImageFileDirectory[]
            If tags(i).Data.[GetType]() Is GetType(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory()) Then
                Dim subIfds As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory() = DirectCast(tags(i).Data, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffImageFileDirectory())
                For j As Integer = 0 To subIfds.Length - 1
                    ' print info about tag collection of sub IFD
                    PrintExifTagCollectionInfo(subIfds(j).Tags, indent & "  ")
                Next
            End If
        Next
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как изменить GPS информацию в JPEG файле:
    public void ChangeGpsInfoAboutJpegFile(string filename)
    {
        // create an instance of JpegFile class
        using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile jpegFile = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename))
        {
            // if JPEG page contains EXIF information
            if (jpegFile.Page.Exif != null)
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData exifData = jpegFile.Page.Exif;
    
                // if EXIF data is found
                if (exifData.ImageFileDirectory != null)
                {
                    // if GPS info is not found
                    if (exifData.ImageFileDirectory.GpsTags == null)
                        // create tag collection that contains GPS info
                        exifData.ImageFileDirectory.GpsTags = 
                            new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection();
    
                    // get reference to a GPS tags
                    Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection gpsTags = 
                        exifData.ImageFileDirectory.GpsTags;
    
                    // search for tag that contains info about GPS date stamp
                    Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag gpsDateStampTag = 
                        gpsTags.Find((ushort)Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp);
                    // if tag that contains info about GPS date stamp is found
                    if (gpsDateStampTag != null)
                        // change the tag data
                        gpsDateStampTag.Data = System.DateTime.Now.ToString();
                    // if tag that contains info about GPS date stamp is not found
                    else
                        // add the GPS date stamp
                        gpsTags.Add((ushort)Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp, 
                            System.DateTime.Now.ToString());
    
                    // save changes to the source file
                    jpegFile.SaveChanges();
                }
            }
        }
    }
    
    Public Sub ChangeGpsInfoAboutJpegFile(filename As String)
        ' create an instance of JpegFile class
        Using jpegFile As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename)
            ' if JPEG page contains EXIF information
            If jpegFile.Page.Exif IsNot Nothing Then
                Dim exifData As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData = jpegFile.Page.Exif
    
                ' if EXIF data is found
                If exifData.ImageFileDirectory IsNot Nothing Then
                    ' if GPS info is not found
                    If exifData.ImageFileDirectory.GpsTags Is Nothing Then
                        ' create tag collection that contains GPS info
                        exifData.ImageFileDirectory.GpsTags = New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection()
                    End If
    
                    ' get reference to a GPS tags
                    Dim gpsTags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection = exifData.ImageFileDirectory.GpsTags
    
                    ' search for tag that contains info about GPS date stamp
                    Dim gpsDateStampTag As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag = gpsTags.Find(CUShort(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp))
                    ' if tag that contains info about GPS date stamp is found
                    If gpsDateStampTag IsNot Nothing Then
                        ' change the tag data
                        gpsDateStampTag.Data = System.DateTime.Now.ToString()
                    Else
                        ' if tag that contains info about GPS date stamp is not found
                        ' add the GPS date stamp
                        gpsTags.Add(CUShort(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.ExifGpsTagId.GPSDateStamp), System.DateTime.Now.ToString())
                    End If
    
                    ' save changes to the source file
                    jpegFile.SaveChanges()
                End If
            End If
        End Using
    End Sub
    


    Вот C#/VB.NET код, который демонстрирует, как получить миниатюру из JPEG файла:
    public Vintasoft.Imaging.VintasoftImage GetJpegThumbnail(string filename)
    {
        // create an instance of JpegFile class
        using (Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile jpegFile = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename))
        {
            // if JPEG page contains EXIF information
            if (jpegFile.Page.Exif != null)
            {
                Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData exifData = jpegFile.Page.Exif;
    
                // if EXIF thumbnail is found
                if (exifData.HasThumbnail)
                    // return thumbnail of JPEG page
                    return exifData.GetThumbnail();
            }
    
            // JPEG page does not have thumbnail
            return null;
        }
    }
    
    Public Function GetJpegThumbnail(filename As String) As Vintasoft.Imaging.VintasoftImage
        ' create an instance of JpegFile class
        Using jpegFile As New Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.JpegFile(filename)
            ' if JPEG page contains EXIF information
            If jpegFile.Page.Exif IsNot Nothing Then
                Dim exifData As Vintasoft.Imaging.Codecs.ImageFiles.Jpeg.ExifData = jpegFile.Page.Exif
    
                ' if EXIF thumbnail is found
                If exifData.HasThumbnail Then
                    ' return thumbnail of JPEG page
                    Return exifData.GetThumbnail()
                End If
            End If
    
            ' JPEG page does not have thumbnail
            Return Nothing
        End Using
    End Function
    


    Доступ к метаданным объекта PdfDocument.

    Класс PdfDocument обеспечивает доступ к PDF документу. Метаданные PDF документа можно получить, используя свойства и методы объекта PdfDocument. Также объект PdfDocument обеспечивает доступ к страницам PDF файла.

    Вот C#/VB.NET код, который демонстрирует, как получить информацию о PDF документе:
    public void GetPdfDocumentInfo(string filename)
    {
        // create an instance of PdfDocument class
        using (Vintasoft.Imaging.Pdf.PdfDocument pdfDocument = 
            new Vintasoft.Imaging.Pdf.PdfDocument(filename))
        {
            System.Console.WriteLine(string.Format("PDF document: '{0}'", filename));
    
            Vintasoft.Imaging.Pdf.Tree.PdfDocumentInformation documentInformation = pdfDocument.DocumentInformation;
            System.Console.WriteLine(string.Format("  Creator: {0}", documentInformation.Creator));
            System.Console.WriteLine(string.Format("  Producer: {0}", documentInformation.Producer));
            System.Console.WriteLine(string.Format("  Creation date: {0}", documentInformation.CreationDate));
            System.Console.WriteLine(string.Format("  Last modification date: {0}", documentInformation.ModifyDate));
            System.Console.WriteLine(string.Format("  Author: {0}", documentInformation.Author));
            System.Console.WriteLine(string.Format("  Title: {0}", documentInformation.Title));
            System.Console.WriteLine(string.Format("  Subject: {0}", documentInformation.Subject));
            System.Console.WriteLine(string.Format("  Keywords: {0}", documentInformation.Keywords));
        }
    }
    
    Public Sub GetPdfDocumentInfo(filename As String)
        ' create an instance of PdfDocument class
        Using pdfDocument As New Vintasoft.Imaging.Pdf.PdfDocument(filename)
            System.Console.WriteLine(String.Format("PDF document: '{0}'", filename))
    
            Dim documentInformation As Vintasoft.Imaging.Pdf.Tree.PdfDocumentInformation = pdfDocument.DocumentInformation
            System.Console.WriteLine(String.Format("  Creator: {0}", documentInformation.Creator))
            System.Console.WriteLine(String.Format("  Producer: {0}", documentInformation.Producer))
            System.Console.WriteLine(String.Format("  Creation date: {0}", documentInformation.CreationDate))
            System.Console.WriteLine(String.Format("  Last modification date: {0}", documentInformation.ModifyDate))
            System.Console.WriteLine(String.Format("  Author: {0}", documentInformation.Author))
            System.Console.WriteLine(String.Format("  Title: {0}", documentInformation.Title))
            System.Console.WriteLine(String.Format("  Subject: {0}", documentInformation.Subject))
            System.Console.WriteLine(String.Format("  Keywords: {0}", documentInformation.Keywords))
        End Using
    End Sub
    


    Класс PdfPage обеспечивает доступ к PDF странице документа. Метаданные PDF страницы можно получить, используя свойства и методы объекта PdfPage.


    Вот C#/VB.NET код, который демонстрирует, как получить размер страницы PDF документа:
    public System.Drawing.SizeF GetFirstPdfPageSize(string filename)
    {
        // create an instance of PdfDocument class
        using (Vintasoft.Imaging.Pdf.PdfDocument pdfDocument =
            new Vintasoft.Imaging.Pdf.PdfDocument(filename))
        {
            if (pdfDocument.Pages.Count == 0)
                return System.Drawing.SizeF.Empty;
    
            return pdfDocument.Pages[0].Size;
        }
    }
    
    Public Function GetFirstPdfPageSize(filename As String) As System.Drawing.SizeF
        ' create an instance of PdfDocument class
        Using pdfDocument As New Vintasoft.Imaging.Pdf.PdfDocument(filename)
            If pdfDocument.Pages.Count = 0 Then
                Return System.Drawing.SizeF.Empty
            End If
    
            Return pdfDocument.Pages(0).Size
        End Using
    End Function
    


    Вот C#/VB.NET код, который демонстрирует, как получить миниатюру cтраницы PDF документа:
    public Vintasoft.Imaging.VintasoftImage GetFirstPdfPageThumbnail(string filename)
    {
        // create an instance of PdfDocument class
        using (Vintasoft.Imaging.Pdf.PdfDocument pdfDocument = 
            new Vintasoft.Imaging.Pdf.PdfDocument(filename))
        {
            if (pdfDocument.Pages.Count == 0)
                return null;
    
            return pdfDocument.Pages[0].GetThumbnail(100, 100);
        }
    }
    
    Public Function GetFirstPdfPageThumbnail(filename As String) As Vintasoft.Imaging.VintasoftImage
        ' create an instance of PdfDocument class
        Using pdfDocument As New Vintasoft.Imaging.Pdf.PdfDocument(filename)
            If pdfDocument.Pages.Count = 0 Then
                Return Nothing
            End If
    
            Return pdfDocument.Pages(0).GetThumbnail(100, 100)
        End Using
    End Function