Created
May 4, 2021 20:00
Add or Remove Custom XMP Metadata from GIF images in C# using GroupDocs.Metadata for .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add or Remove Custom XMP Metadata from GIF images using C# | |
1. Add Custom XMP Metadata Package to GIF using C# | |
2. Read Custom XMP Metadata Package Properties using C# | |
3. Remove Custom XMP Metadata Package using C# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Metadata metadata = new Metadata(@"C:\Files\xmp.gif")) { | |
IXmp root = (IXmp)metadata.GetRootPackage(); | |
XmpPacketWrapper packet = new XmpPacketWrapper(); | |
XmpPackage custom = new XmpPackage("gd", "https://groupdocs.com"); | |
custom.Set("gd:Copyright", "Copyright (C) 2021 GroupDocs. All Rights Reserved."); | |
custom.Set("gd:CreationDate", DateTime.Now.ToString()); | |
custom.Set("gd:Company", XmpArray.From(new String[] { "Aspose", "GroupDocs" }, XmpArrayType.Ordered)); | |
packet.AddPackage(custom); | |
root.XmpPackage = packet; | |
metadata.Save(@"C:\Files\xmp_output.gif"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string file = @"C:\Files\xmp_output.gif"; | |
using (Metadata metadata = new Metadata(file)) | |
{ | |
IXmp root = (IXmp)metadata.GetRootPackage(); | |
if (root.XmpPackage != null) | |
{ | |
foreach (var package in root.XmpPackage.Packages) | |
{ | |
Console.WriteLine(package.NamespaceUri); | |
Console.WriteLine(package.Prefix); | |
foreach(var keys in package.Keys) | |
{ | |
var property = package.FindProperties(p => p.Name == keys).FirstOrDefault(); | |
Console.WriteLine(property.Name + " : " + property.Value); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Metadata metadata = new Metadata(@"C:\Files\xmp_output.gif")) | |
{ | |
IXmp root = (IXmp)metadata.GetRootPackage(); | |
root.XmpPackage = null; | |
metadata.Save(@"C:\Files\xmp_output_Removed.gif"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment