VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
In This Topic
TIFF: How to modify tags of TIFF file?
In This Topic
Here is C#/VB.NET code that shows how to add/modify/delete tags of TIFF file:
namespace UserGuide.Programming.Tiff
{
    class ModifyTagsOfTIFF
    {

        public void ModifyTiffTags(System.IO.Stream stream)
        {
            // open TIFF file
            using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiff = 
                new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream))
            {
                // get access to tag collection of the first page of TIFF file
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection tags = tiff.Pages[0].IFD.Tags;

                // add tags
                tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Software, "VintaSoft Imaging .NET SDK v8.2");
                tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Make, "VintaSoft LLC.");
                tags.Add((ushort)0xE001, "BarcodeInfo");

                // modify or add tag
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag dateTimeTag = tags.Find(
                    Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.DateTime);
                if (dateTimeTag != null)
                    dateTimeTag.Data = "25/05/2012 11:45:51";
                else
                    tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.DateTime, "25/05/2012 11:45:51");

                // remove tag
                tags.Remove(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Make);

                // save changes
                tiff.SaveChanges();
            }
        }

    }
}
Namespace UserGuide.Programming.Tiff
    Class ModifyTagsOfTIFF

        Public Sub ModifyTiffTags(stream As System.IO.Stream)
            ' open TIFF file
            Using tiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream)
                ' get access to tag collection of the first page of TIFF file
                Dim tags As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagCollection = tiff.Pages(0).IFD.Tags

                ' add tags
                tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Software, "VintaSoft Imaging .NET SDK v8.2")
                tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Make, "VintaSoft LLC.")
                tags.Add(CUShort(&He001), "BarcodeInfo")

                ' modify or add tag
                Dim dateTimeTag As Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTag = tags.Find(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.DateTime)
                If dateTimeTag IsNot Nothing Then
                    dateTimeTag.Data = "25/05/2012 11:45:51"
                Else
                    tags.Add(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.DateTime, "25/05/2012 11:45:51")
                End If

                ' remove tag
                tags.Remove(Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffTagId.Make)

                ' save changes
                tiff.SaveChanges()
            End Using
        End Sub

    End Class
End Namespace