The Extensible Metadata Platform (XMP) is an XML-based ISO metadata standard, originally created by Adobe Systems Inc. It defines a data structure, serialization model and basic metadata properties intended to form a unified metadata package that can be embedded into different media formats. The defined XMP data model can be used to store any set of metadata properties. These can be simple name/value pairs, structured values or lists of values. The data can be nested as well.
To access XMP metadata in a file of any supported format, GroupDocs.Metadata provides the IXmp.XmpPackage property. The following are the steps to read XMP metadata:
GroupDocs.Metadata also provides an API allowing users to work with fully custom XMP schemes/packages. Please refer to this code snippet to learn more.
Updating XMP properties
The GroupDocs.Metadata API facilitates the user to update XMP metadata in a convenient way - using the XmpPacketWrapper class properties. Follow the below steps to update XMP metadata in a file of any supported format.
using(Metadatametadata=newMetadata(Constants.GifWithXmp)){IXmproot=metadata.GetRootPackage()asIXmp;if(root!=null&&root.XmpPackage!=null){// if there is no such scheme in the XMP package we should create itif(root.XmpPackage.Schemes.DublinCore==null){root.XmpPackage.Schemes.DublinCore=newXmpDublinCorePackage();}root.XmpPackage.Schemes.DublinCore.Format="image/gif";root.XmpPackage.Schemes.DublinCore.SetRights("Copyright (C) 2011-2019 GroupDocs. All Rights Reserved");root.XmpPackage.Schemes.DublinCore.SetSubject("test");if(root.XmpPackage.Schemes.CameraRaw==null){root.XmpPackage.Schemes.CameraRaw=newXmpCameraRawPackage();}root.XmpPackage.Schemes.CameraRaw.Shadows=50;root.XmpPackage.Schemes.CameraRaw.AutoBrightness=true;root.XmpPackage.Schemes.CameraRaw.AutoExposure=true;root.XmpPackage.Schemes.CameraRaw.CameraProfile="test";root.XmpPackage.Schemes.CameraRaw.Exposure=0.0001;// If you don't want to keep the old values just replace the whole schemeroot.XmpPackage.Schemes.XmpBasic=newXmpBasicPackage();root.XmpPackage.Schemes.XmpBasic.CreateDate=DateTime.Today;root.XmpPackage.Schemes.XmpBasic.BaseUrl="https://groupdocs.com";root.XmpPackage.Schemes.XmpBasic.Rating=5;root.XmpPackage.Schemes.BasicJobTicket=newXmpBasicJobTicketPackage();// Set a complex type propertyroot.XmpPackage.Schemes.BasicJobTicket.Jobs=new[]{newXmpJob{ID="1",Name="test job",Url="https://groupdocs.com"},};// ... metadata.Save(Constants.OutputGif);}}
Adding a custom XMP package
The GroupDocs.Metadata API provides access to a number of commonly used XMP schemes. But it also allows you to create fully custom XMP packages containing user-defined properties. The example below demonstrates how to create and add a custom XMP package to a file.
using(Metadatametadata=newMetadata(Constants.InputJpeg)){IXmproot=metadata.GetRootPackage()asIXmp;if(root!=null){varpacket=newXmpPacketWrapper();varcustom=newXmpPackage("gd","https://groupdocs.com");custom.Set("gd:Copyright","Copyright (C) 2011-2019 GroupDocs. All Rights Reserved.");custom.Set("gd:CreationDate",DateTime.Today);custom.Set("gd:Company",XmpArray.From(new[]{"Aspose","GroupDocs"},XmpArrayType.Ordered));packet.AddPackage(custom);root.XmpPackage=packet;metadata.Save(Constants.OutputJpeg);}}
Removing XMP metadata
To remove the XMP package from a file just assign null to the IXmp.XmpPackage property. The code sample below shows how to remove XMP metadata from a file.
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.