←Select platform

Comments Property

Summary
The collection of comment data used when reading and writing certain file formats (including GIF).
Syntax
C#
Objective-C
C++/CLI
Java
Python
public ObservableCollection<RasterCommentMetadata> Comments { get; } 
@property (nonatomic, assign, readonly, nullable) NSMutableArray<LTRasterCommentMetadata *> *comments 
public RasterCollection<RasterCommentMetadata> getComments(); 
public: 
property ObservableCollection<RasterCommentMetadata^>^ Comments { 
   ObservableCollection<RasterCommentMetadata^>^ get(); 
} 
Comments # get  (RasterImage) 

Property Value

A collection of RasterCommentMetadata used when reading and writing certain file formats (including GIF).

Remarks

Several formats allow you to store non-image data such as comments, tags, and markers.

You can manipulate the comments of an image by adding/removing RasterCommentMetadata objects to this collection.

By setting the CodecsSaveOptions.Comments property to true before calling RasterCodecs.Save, you can save the comments in this collection when the image is saved into a file.

By setting the CodecsLoadOptions.Markers property to true before calling RasterCodecs.Load, you can load all the markers (if any) into this collection when an image is loaded from a file.

You can use the RasterCodecs.WriteMarkers method to save the markers directly to an existing file.

For more information, refer to Non Image Data and Types of File Comments.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
private void DisplayComment(RasterCommentMetadata comment) 
{ 
   switch (comment.DataType) 
   { 
      case RasterCommentMetadataDataType.Ascii: 
         Console.WriteLine("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii()); 
         break; 
   } 
} 
public void CommentsExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP")); 
 
   //Ascii 
   RasterCommentMetadata commentDataAscii = new RasterCommentMetadata(); 
   // set the artist comment 
   commentDataAscii.Type = RasterCommentMetadataType.Artist; 
   commentDataAscii.FromAscii("Test String"); 
   image.Comments.Add(commentDataAscii); 
 
   codecs.Options.Save.Comments = true; 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_COMMENTS.TIF"), RasterImageFormat.Tif, 0); 
   // load the comment together with the image 
 
   RasterCommentMetadata comment = codecs.ReadComment(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_COMMENTS.TIF"), 1, RasterCommentMetadataType.Artist); 
   DisplayComment(comment); 
 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.IOException; 
import java.io.InputStream; 
import java.util.ArrayList; 
import java.util.List; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.core.*; 
import leadtools.svg.*; 
import leadtools.imageprocessing.CloneCommand; 
import leadtools.imageprocessing.FillCommand; 
import leadtools.imageprocessing.FlipCommand; 
import leadtools.imageprocessing.GrayscaleCommand; 
import leadtools.imageprocessing.color.InvertCommand; 
import leadtools.imageprocessing.color.PosterizeCommand; 
 
 
public void commentsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "IMAGE1.CMP")); 
 
   // Ascii 
   RasterCommentMetadata commentDataAscii = new RasterCommentMetadata(); 
 
   // Set the artist comment 
   commentDataAscii.setType(RasterCommentMetadataType.ARTIST); 
   commentDataAscii.fromAscii("Test String"); 
   image.getComments().add(commentDataAscii); 
   codecs.getOptions().getSave().setComments(true); 
 
   // Save it 
   codecs.save(image, combine(LEAD_VARS_IMAGES_DIR, "IMAGE_TEST_COMMENTS.TIF"), RasterImageFormat.TIF, 0); 
 
   // Load the comment together with the image 
   RasterCommentMetadata comment = codecs.readComment(combine(LEAD_VARS_IMAGES_DIR, "IMAGE_TEST_COMMENTS.TIF"), 1, 
         RasterCommentMetadataType.ARTIST); 
   displayComment(comment); 
   codecs.dispose(); 
 
   assertTrue("Image saved unsuccessfully", 
         (new File(combine(LEAD_VARS_IMAGES_DIR, "IMAGE_TEST_COMMENTS.TIF"))).exists()); 
   System.out.println("Image saved to: " + combine(LEAD_VARS_IMAGES_DIR, "IMAGE_TEST_COMMENTS.TIF")); 
} 
 
private void displayComment(RasterCommentMetadata comment) { 
 
   switch (comment.getDataType()) { 
      case ASCII: 
         System.out.println("Comment of type " + comment.getDataType().toString() + " = " + comment.toAscii()); 
         break; 
      case BYTE: 
      case INT_16: 
      case RATIONAL: 
      case URATIONAL: 
      default: 
         break; 
   } 
 
} 
Requirements

Target Platforms

Help Version 23.0.2024.5.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.