#1
Posted
:
Thursday, June 1, 2017 4:10:26 PM(UTC)
Groups: Registered
Posts: 119
Was thanked: 4 time(s) in 4 post(s)
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.
Below is the code that you would need to add file metadata comments to a .JP2 image.
Code:
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(input);
RasterCommentMetadata jp2comment = new RasterCommentMetadata();
// set the comment
jp2comment.Type = RasterCommentMetadataType.Jpeg2000Latin;
jp2comment.FromAscii("This is a test string to load metadata to a JP2 image");
image.Comments.Add(jp2comment);
codecs.Options.Save.Comments = true;
codecs.Save(image, dest, RasterImageFormat.Jp2, 0);
// load the comment together with the image
RasterCommentMetadata comment = codecs.ReadComment(dest, 1, RasterCommentMetadataType.Jpeg2000Latin);
Console.WriteLine("Comment of type " + comment.Type.ToString() + " = " + comment.ToAscii());
Here is a screenshot of the outcome from the code above:
Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.