LEADTOOLS (Leadtools assembly)

CopyMetadataTo Method

Show in webframe
Example 







Destination image
Type of metadata to copy
Copies the metadata (tags, comments, and markers) to the given image.
Syntax
public void CopyMetadataTo( 
   RasterImage image,
   RasterMetadataFlags flags
)
'Declaration
 
Public Sub CopyMetadataTo( _
   ByVal image As RasterImage, _
   ByVal flags As RasterMetadataFlags _
) 
'Usage
 
Dim instance As RasterImage
Dim image As RasterImage
Dim flags As RasterMetadataFlags
 
instance.CopyMetadataTo(image, flags)
public void CopyMetadataTo( 
   RasterImage image,
   RasterMetadataFlags flags
)
-(void)copyMetadataTo:(LTRasterImage*)image 
                flags:(LTRasterMetadataFlags)flags;
            
public void copyMetadataTo(
  RasterImage image, 
  int flags
)
            
 function Leadtools.RasterImage.CopyMetadataTo( 
   image ,
   flags 
)
public:
void CopyMetadataTo( 
   RasterImage^ image,
   RasterMetadataFlags flags
) 

Parameters

image
Destination image
flags
Type of metadata to copy
Remarks

This methods copies the metadata found in the Tags, Comments and/or Markers collections of this RasterImage to image.

Before the copy operation, this method will clear any metadata already found in image.

For more information on GeoKeys, refer to Implementing GeoKeys (GeoTIFF tags).

For more information, refer to Non Image Data.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.WinForms
Imports Leadtools.Dicom
Imports Leadtools.Drawing

Public Sub CopyMetadataToExample()
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' load 2 TIF images
   Dim image1 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "OCR1.TIF"))
   Dim image2 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "OCR2.TIF"))

   ' show the number of tags in each image
   MessageBox.Show(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   ' add a few tags to the first image
   Dim tag As RasterTagMetadata = New RasterTagMetadata(RasterTagMetadata.Copyright, RasterTagMetadataDataType.Byte, New Byte() {1, 2, 3})
   image1.Tags.Add(tag)

   tag = New RasterTagMetadata(RasterTagMetadata.ExifGps, RasterTagMetadataDataType.Byte, New Byte() {4, 5, 6})
   image1.Tags.Add(tag)

   ' show the number of tags in each image
   MessageBox.Show(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   ' copy the tags from first image to the second
   image1.CopyMetadataTo(image2, RasterMetadataFlags.Tags)

   ' show the number of tags in each image
   MessageBox.Show(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   image1.Dispose()
   image2.Dispose()
   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.WinForms;
using Leadtools.Dicom;
using Leadtools.Drawing;

      
public void CopyMetadataToExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // load 2 TIF images
   RasterImage image1 = codecs.Load(Path.Combine(ImagesPath.Path, "OCR1.TIF"));
   RasterImage image2 = codecs.Load(Path.Combine(ImagesPath.Path, "OCR2.TIF"));
   // show the number of tags in each image
   MessageBox.Show(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // add a few tags to the first image
   RasterTagMetadata tag = new RasterTagMetadata(RasterTagMetadata.Copyright, RasterTagMetadataDataType.Byte, new byte[] { 1, 2, 3 });
   image1.Tags.Add(tag);

   tag = new RasterTagMetadata(RasterTagMetadata.ExifGps, RasterTagMetadataDataType.Byte, new byte[] { 4, 5, 6 });
   image1.Tags.Add(tag);

   // show the number of tags in each image
   MessageBox.Show(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // copy the tags from first image to the second
   image1.CopyMetadataTo(image2, RasterMetadataFlags.Tags);

   // show the number of tags in each image
   MessageBox.Show(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   image1.Dispose();
   image2.Dispose();
   codecs.Dispose();
}
RasterImageExamples.prototype.CopyMetadataToExample = function () {
   Tools.SetLicense();

   with (Leadtools) {
      with (Leadtools.Codecs) {
         var codecs = new RasterCodecs();

         // load 2 TIF images
         var srcFileName = "Assets\\OCR1.TIF";
         var image1;
         var image2;
         return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
            return codecs.loadAsync(LeadStreamFactory.create(loadFile))
         })
            .then(function (img1) {
               image1 = img1;

               srcFileName = "Assets\\OCR2.TIF";
               return Tools.AppInstallFolder().getFileAsync(srcFileName)
            })
            .then(function (loadFile) {
               return codecs.loadAsync(LeadStreamFactory.create(loadFile))
            })
            .then(function (img2) {
               image2 = img2;
               // show the number of tags in each image
               console.info("Tags in image1: " + image1.tags.length + ", tags in image2: " + image2.tags.length);

               // add a few tags to the first image
               var tag = new RasterTagMetadata(RasterTagMetadata.copyright, RasterTagMetadataDataType.byte, [1, 2, 3]);
               image1.tags.append(tag);

               tag = new RasterTagMetadata(RasterTagMetadata.exifGps, RasterTagMetadataDataType.byte, [4, 5, 6]);
               image1.tags.append(tag);

               // show the number of tags in each image
               console.info("Tags in image1: " + image1.tags.length + ", tags in image2: " + image2.tags.length);

               // copy the tags from first image to the second
               image1.copyMetadataTo(image2, RasterMetadataFlags.tags);

               // show the number of tags in each image
               console.info("Tags in image1: " + image1.tags.length + ", tags in image2: " + image2.tags.length);

               image1.close();
               image2.close();
               codecs.close();
            });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;

      
public async Task CopyMetadataToExample()
{
   RasterCodecs codecs = new RasterCodecs();
   // load 2 TIF images
   string srcFileName = @"Assets\OCR1.TIF";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image1 = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));
   srcFileName = @"Assets\OCR2.TIF";
   loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image2 = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // add a few tags to the first image
   RasterTagMetadata tag = new RasterTagMetadata(RasterTagMetadata.Copyright, RasterTagMetadataDataType.Byte, new byte[] { 1, 2, 3 });
   image1.Tags.Add(tag);

   tag = new RasterTagMetadata(RasterTagMetadata.ExifGps, RasterTagMetadataDataType.Byte, new byte[] { 4, 5, 6 });
   image1.Tags.Add(tag);

   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // copy the tags from first image to the second
   image1.CopyMetadataTo(image2, RasterMetadataFlags.Tags);

   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   image1.Dispose();
   image2.Dispose();
   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Dicom;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Examples;
using Leadtools.Windows.Media;

public void CopyMetadataToExample(RasterImage image1, RasterImage image2)
{
   // images should be 2 TIF images
   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // add a few tags to the first image
   RasterTagMetadata tag = new RasterTagMetadata(RasterTagMetadata.Copyright, RasterTagMetadataDataType.Byte, new byte[] { 1, 2, 3 });
   image1.Tags.Add(tag);

   tag = new RasterTagMetadata(RasterTagMetadata.ExifGps, RasterTagMetadataDataType.Byte, new byte[] { 4, 5, 6 });
   image1.Tags.Add(tag);

   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   // copy the tags from first image to the second
   image1.CopyMetadataTo(image2, RasterMetadataFlags.Tags);

   // show the number of tags in each image
   Debug.WriteLine(string.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count));

   image1.Dispose();
   image2.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Dicom
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Public Sub CopyMetadataToExample(ByVal image1 As RasterImage, ByVal image2 As RasterImage)
   ' images should be 2 TIF images
   ' show the number of tags in each image
   Debug.WriteLine(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   ' add a few tags to the first image
   Dim tag As RasterTagMetadata = New RasterTagMetadata(RasterTagMetadata.Copyright, RasterTagMetadataDataType.Byte, New Byte() { 1, 2, 3 })
   image1.Tags.Add(tag)

   tag = New RasterTagMetadata(RasterTagMetadata.ExifGps, RasterTagMetadataDataType.Byte, New Byte() { 4, 5, 6 })
   image1.Tags.Add(tag)

   ' show the number of tags in each image
   Debug.WriteLine(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   ' copy the tags from first image to the second
   image1.CopyMetadataTo(image2, RasterMetadataFlags.Tags)

   ' show the number of tags in each image
   Debug.WriteLine(String.Format("Tags in image1: {0}, tags in image2: {1}", image1.Tags.Count, image2.Tags.Count))

   image1.Dispose()
   image2.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

RasterImage Class
RasterImage Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.