Working with XMP metadata

What is XMP?

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.

Note
Please find more information on the XMP standard at https://en.wikipedia.org/wiki/Extensible_Metadata_Platform

Reading XMP properties

To access XMP metadata in a file of any supported format, GroupDocs.Metadata provides the IXmp.getXmpPackage method. The following are the steps to read XMP metadata:

  1. Load a file that contains XMP metadata
  2. Extract the XMP metadata package using the IXmp.getXmpPackage method

The following code snippet gets XMP properties of a PNG image and displays them on the screen. 

advanced_usage.working_with_metadata_standards.xmp.ReadXmpProperties

const metadata = new groupdocs.metadata.Metadata(Constants.PngWithXmp);
    var root = metadata.getRootPackage();
            if (root.getXmpPackage() != null) {
                if (root.getXmpPackage().getSchemes().getXmpBasic() != null) {
                    console.log(root.getXmpPackage().getSchemes().getXmpBasic().getCreatorTool());
                    console.log(root.getXmpPackage().getSchemes().getXmpBasic().getCreateDate());
                }

                if (root.getXmpPackage().getSchemes().getDublinCore() != null) {
                    console.log(root.getXmpPackage().getSchemes().getDublinCore().getFormat());
                    console.log(root.getXmpPackage().getSchemes().getDublinCore().getCoverage());
                }

                if (root.getXmpPackage().getSchemes().getPhotoshop() != null) {
                    console.log(root.getXmpPackage().getSchemes().getPhotoshop().getColorMode());
                    console.log(root.getXmpPackage().getSchemes().getPhotoshop().getIccProfile());
                }
            }

Here is a full list of supported XMP schemes:

  • mpBasicJobTicketPackage
  • mpBasicPackage
  • mpCameraRawPackage
  • mpDublinCorePackage
  • mpDynamicMediaPackage
  • mpIptcCorePackage
  • mpIptcExtensionPackage
  • mpIptcIimPackage
  • mpMediaManagementPackage
  • mpPagedTextPackage
  • mpPdfPackage
  • mpPhotoshopPackage
  • mpRightsManagementPackage
Note
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.

Removing XMP metadata

To remove the XMP package from a file just pass null to the IXmp.setXmpPackage method as a parameter. The code sample below shows how to remove XMP metadata from a file.

advanced_usage.working_with_metadata_standards.xmp.AddCustomXmpPackage

 const metadata = new groupdocs.metadata.Metadata(Constants.JpegWithXmp);
    var root = metadata.getRootPackage();
    root.setXmpPackage(null);
    metadata.save(Constants.OutputJpeg);
}

More resources

Advanced usage topics

To learn more about library features and get familiar how to manage metadata and more, please refer to theadvanced usage section.

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document metadata management App

Along with a full featured Java 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.